Skip to content

Commit

Permalink
Merge pull request #1881 from gioman/fix_processing_gdal_dstnodata
Browse files Browse the repository at this point in the history
fix processing gdalwarp dstnodata
  • Loading branch information
alexbruy committed Feb 4, 2015
2 parents 91c4e7a + 1fe580c commit 421dfb2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
9 changes: 5 additions & 4 deletions python/plugins/processing/algs/gdal/ClipByMask.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def defineCharacteristics(self):
self.addParameter(ParameterVector(self.MASK, self.tr('Mask layer'),
[ParameterVector.VECTOR_TYPE_POLYGON]))
self.addParameter(ParameterString(self.NO_DATA,
self.tr("Nodata value, leave as 'none' to take the nodata value from input"),
'none'))
self.tr("Nodata value, leave blank to take the nodata value from input"),
'-9999'))
self.addParameter(ParameterBoolean(self.ALPHA_BAND,
self.tr('Create and output alpha band'), False))
self.addParameter(ParameterBoolean(self.KEEP_RESOLUTION,
Expand All @@ -78,8 +78,9 @@ def processAlgorithm(self, progress):
arguments.append('-q')
arguments.append('-of')
arguments.append(GdalUtils.getFormatShortNameFromFilename(out))
arguments.append('-dstnodata')
arguments.append(noData)
if len(noData) > 0:
arguments.append('-dstnodata')
arguments.append(noData)

if keepResolution:
r = gdal.Open(self.getParameterValue(self.INPUT))
Expand Down
25 changes: 18 additions & 7 deletions python/plugins/processing/algs/gdal/warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class warp(GdalAlgorithm):
METHOD = 'METHOD'
METHOD_OPTIONS = ['near', 'bilinear', 'cubic', 'cubicspline', 'lanczos']
TR = 'TR'
NO_DATA = 'NO_DATA'
EXTRA = 'EXTRA'
RTYPE = 'RTYPE'

Expand All @@ -54,9 +55,12 @@ def defineCharacteristics(self):
self.group = '[GDAL] Projections'
self.addParameter(ParameterRaster(self.INPUT, self.tr('Input layer'), False))
self.addParameter(ParameterCrs(self.SOURCE_SRS,
self.tr('Source SRS'), 'EPSG:4326'))
self.tr('Source SRS'), ''))
self.addParameter(ParameterCrs(self.DEST_SRS,
self.tr('Destination SRS'), 'EPSG:4326'))
self.tr('Destination SRS'), ''))
self.addParameter(ParameterString(self.NO_DATA,
self.tr("Nodata value, leave blank to take the nodata value from input"),
'-9999'))
self.addParameter(ParameterNumber(self.TR,
self.tr('Output file resolution in target georeferenced units (leave 0 for no change)'),
0.0, None, 0.0))
Expand All @@ -70,14 +74,21 @@ def defineCharacteristics(self):
self.addOutput(OutputRaster(self.OUTPUT, self.tr('Output layer')))

def processAlgorithm(self, progress):
noData = str(self.getParameterValue(self.NO_DATA))
srccrs = self.getParameterValue(self.SOURCE_SRS)
dstcrs = self.getParameterValue(self.DEST_SRS)
arguments = []
arguments.append('-ot')
arguments.append(self.TYPE[self.getParameterValue(self.RTYPE)])
arguments.append('-s_srs')
arguments.append(str(self.getParameterValue(self.SOURCE_SRS)))
arguments.append('-t_srs')
crsId = self.getParameterValue(self.DEST_SRS)
arguments.append(str(crsId))
if len(srccrs) > 0:
arguments.append('-s_srs')
arguments.append(srccrs)
if len(dstcrs) > 0:
arguments.append('-t_srs')
arguments.append(dstcrs)
if len(noData) > 0:
arguments.append('-dstnodata')
arguments.append(noData)
arguments.append('-r')
arguments.append(
self.METHOD_OPTIONS[self.getParameterValue(self.METHOD)])
Expand Down

0 comments on commit 421dfb2

Please sign in to comment.