Skip to content
Permalink
Browse files

fix gdal rasterize when using an existing raster layer

  • Loading branch information
Giovanni Manghi authored and alexbruy committed Apr 9, 2015
1 parent 66580c4 commit 02bec584a897167a767198637c77b83898ccd36a
Showing with 17 additions and 15 deletions.
  1. +17 −15 python/plugins/processing/algs/gdal/rasterize.py
@@ -101,9 +101,9 @@ def defineCharacteristics(self):
self.addParameter(ParameterSelection(self.BIGTIFF,
self.tr('Control whether the created file is a BigTIFF or a classic TIFF'), self.BIGTIFFTYPE, 0))
self.addParameter(ParameterBoolean(self.TFW,
self.tr('Force the generation of an associated ESRI world file (.tfw))'), False))
self.tr('Force the generation of an associated ESRI world file (.tfw)'), False))
self.addOutput(OutputRaster(self.OUTPUT,
self.tr('Output layer: mandatory to choose an existing raster layer if the (*) option is selected')))
self.tr('Output layer: mandatory if the (*) option is selected')))

def processAlgorithm(self, progress):
writeOver = self.getParameterValue(self.WRITEOVER)
@@ -127,19 +127,21 @@ def processAlgorithm(self, progress):
arguments.append('-ot')
arguments.append(self.TYPE[self.getParameterValue(self.RTYPE)])
dimType = self.getParameterValue(self.DIMENSIONS)
if dimType == 0:
# size in pixels
arguments.append('-ts')
arguments.append(str(self.getParameterValue(self.WIDTH)))
arguments.append(str(self.getParameterValue(self.HEIGHT)))
else:
# resolution in map units per pixel
arguments.append('-tr')
arguments.append(str(self.getParameterValue(self.WIDTH)))
arguments.append(str(self.getParameterValue(self.HEIGHT)))
if len(noData) > 0:
arguments.append('-a_nodata')
arguments.append(noData)
if not writeOver:
if dimType == 0:
# size in pixels
arguments.append('-ts')
arguments.append(str(self.getParameterValue(self.WIDTH)))
arguments.append(str(self.getParameterValue(self.HEIGHT)))
else:
# resolution in map units per pixel
arguments.append('-tr')
arguments.append(str(self.getParameterValue(self.WIDTH)))
arguments.append(str(self.getParameterValue(self.HEIGHT)))
if not writeOver:
if len(noData) > 0:
arguments.append('-a_nodata')
arguments.append(noData)
if (GdalUtils.getFormatShortNameFromFilename(out) == "GTiff") and (writeOver is False):
arguments.append("-co COMPRESS="+compress)
if compress == 'JPEG':

0 comments on commit 02bec58

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