Skip to content
Permalink
Browse files

Merge pull request #1881 from gioman/fix_processing_gdal_dstnodata

fix processing gdalwarp dstnodata
  • Loading branch information
alexbruy committed Feb 4, 2015
2 parents 91c4e7a + 1fe580c commit 421dfb22597fcc4530e07af87ec0e91263067190
Showing with 23 additions and 11 deletions.
  1. +5 −4 python/plugins/processing/algs/gdal/ClipByMask.py
  2. +18 −7 python/plugins/processing/algs/gdal/warp.py
@@ -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,
@@ -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))
@@ -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'

@@ -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))
@@ -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)])

0 comments on commit 421dfb2

Please sign in to comment.
You can’t perform that action at this time.