Skip to content
Permalink
Browse files
Merge pull request #45022 from qgis/backport-45005-to-queued_ltr_back…
…ports

[Backport queued_ltr_backports] [processing] Fix NODATA parameters in GDAL Merge algorithm
  • Loading branch information
rouault committed Sep 11, 2021
2 parents 0abd95c + 2aa1135 commit dbba1edbcf891e40207562262b2f679a838f7597
@@ -71,15 +71,15 @@ def initAlgorithm(self, config=None):

nodata_param = QgsProcessingParameterNumber(self.NODATA_INPUT,
self.tr('Input pixel value to treat as "nodata"'),
type=QgsProcessingParameterNumber.Integer,
type=QgsProcessingParameterNumber.Double,
defaultValue=None,
optional=True)
nodata_param.setFlags(nodata_param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
self.addParameter(nodata_param)

nodata_out_param = QgsProcessingParameterNumber(self.NODATA_OUTPUT,
self.tr('Assign specified "nodata" value to output'),
type=QgsProcessingParameterNumber.Integer,
type=QgsProcessingParameterNumber.Double,
defaultValue=None,
optional=True)
nodata_out_param.setFlags(nodata_out_param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
@@ -141,12 +141,12 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-separate')

if self.NODATA_INPUT in parameters and parameters[self.NODATA_INPUT] is not None:
nodata_input = self.parameterAsInt(parameters, self.NODATA_INPUT, context)
nodata_input = self.parameterAsDouble(parameters, self.NODATA_INPUT, context)
arguments.append('-n')
arguments.append(str(nodata_input))

if self.NODATA_OUTPUT in parameters and parameters[self.NODATA_OUTPUT] is not None:
nodata_output = self.parameterAsInt(parameters, self.NODATA_OUTPUT, context)
nodata_output = self.parameterAsDouble(parameters, self.NODATA_OUTPUT, context)
arguments.append('-a_nodata')
arguments.append(str(nodata_output))

@@ -1974,7 +1974,7 @@ def testMerge(self):
cmd[1] = t[:t.find('--optfile') + 10] + t[t.find('mergeInputFiles.txt'):]
self.assertEqual(cmd,
['gdal_merge.py',
'-a_nodata -9999 -ot Float32 -of GTiff ' +
'-a_nodata -9999.0 -ot Float32 -of GTiff ' +
'-o ' + outdir + '/check.tif ' +
'--optfile mergeInputFiles.txt'])

0 comments on commit dbba1ed

Please sign in to comment.