Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
LETG
Rename bands
Commits
9b4cdf3c
Commit
9b4cdf3c
authored
Sep 17, 2021
by
PIERSON Julie
Browse files
adding parameter for no data value used in merge alg
parent
34c29dde
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
merge_rename_bands_algorithm.py
merge_rename_bands_algorithm.py
+15
-0
No files found.
merge_rename_bands_algorithm.py
View file @
9b4cdf3c
...
...
@@ -34,6 +34,7 @@ from qgis.PyQt.QtCore import QCoreApplication
from
qgis.core
import
(
QgsProcessingAlgorithm
,
QgsProject
,
QgsProcessingParameterDefinition
,
QgsProcessingParameterNumber
,
QgsProcessingParameterRasterDestination
)
import
processing
from
osgeo
import
gdal
...
...
@@ -79,6 +80,7 @@ class MergeAndRenameAlgorithm(QgsProcessingAlgorithm):
# calling from the QGIS console.
INPUT
=
'INPUT'
NODATA
=
'NODATA'
OUTPUT
=
'OUTPUT'
def
initAlgorithm
(
self
,
config
):
...
...
@@ -95,6 +97,17 @@ class MergeAndRenameAlgorithm(QgsProcessingAlgorithm):
False
# True if optional
)
)
# parameter for no data value
self
.
addParameter
(
QgsProcessingParameterNumber
(
self
.
NODATA
,
self
.
tr
(
'No data value'
),
type
=
QgsProcessingParameterNumber
.
Integer
,
defaultValue
=
0
,
optional
=
True
)
)
# output raster layer
self
.
addParameter
(
...
...
@@ -112,6 +125,7 @@ class MergeAndRenameAlgorithm(QgsProcessingAlgorithm):
# RETRIEVE INPUTS AND OUTPUT
input_param
=
ParameterMergeBandTable
.
tableValuesAsList
(
parameters
[
self
.
INPUT
])
nodata
=
self
.
parameterAsDouble
(
parameters
,
self
.
NODATA
,
context
)
output_raster_path
=
self
.
parameterAsOutputLayer
(
parameters
,
self
.
OUTPUT
,
context
)
# GETTING USEFUL PARAMETERS
...
...
@@ -136,6 +150,7 @@ class MergeAndRenameAlgorithm(QgsProcessingAlgorithm):
merge_param
=
{
'INPUT'
:
rasterPaths
,
'SEPARATE'
:
True
,
'NODATA_OUTPUT'
:
nodata
,
'OUTPUT'
:
output_raster_path
}
processing
.
run
(
"gdal:merge"
,
merge_param
,
context
=
context
,
feedback
=
feedback
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment