Commit 9b4cdf3c authored by PIERSON Julie's avatar PIERSON Julie
Browse files

adding parameter for no data value used in merge alg

parent 34c29dde
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment