Skip to content

Commit

Permalink
[processing][gdal] More nodata handling fixes
Browse files Browse the repository at this point in the history
Fixes #18748
  • Loading branch information
nyalldawson committed May 6, 2018
1 parent 739d4fa commit bddcb7d
Show file tree
Hide file tree
Showing 5 changed files with 374 additions and 8 deletions.
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/gdal/gdal2tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-s')
arguments.append(crs.authid())

nodata = self.parameterAsDouble(parameters, self.NODATA, context)
if nodata:
if self.NODATA in parameters and parameters[self.NODATA] is not None:
nodata = self.parameterAsDouble(parameters, self.NODATA, context)
arguments.append('-a')
arguments.append(str(nodata))

Expand Down
7 changes: 5 additions & 2 deletions python/plugins/processing/algs/gdal/proximity.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
distance = self.parameterAsDouble(parameters, self.MAX_DISTANCE, context)
replaceValue = self.parameterAsDouble(parameters, self.REPLACE, context)
nodata = self.parameterAsDouble(parameters, self.NODATA, context)
if self.NODATA in parameters and parameters[self.NODATA] is not None:
nodata = self.parameterAsDouble(parameters, self.NODATA, context)
else:
nodata = None
options = self.parameterAsString(parameters, self.OPTIONS, context)
out = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)

Expand All @@ -158,7 +161,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-maxdist')
arguments.append(str(distance))

if nodata:
if nodata is not None:
arguments.append('-nodata')
arguments.append(str(nodata))

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/gdal/rasterize.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
if self.parameterAsBool(parameters, self.ALL_TOUCH, context):
arguments.append('-at')

nodata = self.parameterAsDouble(parameters, self.NODATA, context)
if nodata:
if self.NODATA in parameters and parameters[self.NODATA] is not None:
nodata = self.parameterAsDouble(parameters, self.NODATA, context)
arguments.append('-a_nodata')
arguments.append(nodata)

Expand Down
7 changes: 5 additions & 2 deletions python/plugins/processing/algs/gdal/warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
out = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
sourceCrs = self.parameterAsCrs(parameters, self.SOURCE_CRS, context)
targetCrs = self.parameterAsCrs(parameters, self.TARGET_CRS, context)
nodata = self.parameterAsDouble(parameters, self.NODATA, context)
if self.NODATA in parameters and parameters[self.NODATA] is not None:
nodata = self.parameterAsDouble(parameters, self.NODATA, context)
else:
nodata = None
resolution = self.parameterAsDouble(parameters, self.TARGET_RESOLUTION, context)

arguments = []
Expand All @@ -178,7 +181,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-t_srs')
arguments.append(targetCrs.authid())

if nodata:
if nodata is not None:
arguments.append('-dstnodata')
arguments.append(str(nodata))

Expand Down
Loading

0 comments on commit bddcb7d

Please sign in to comment.