diff --git a/python/plugins/processing/algs/gdal/warp.py b/python/plugins/processing/algs/gdal/warp.py index 406648510d4..2fb100a8057 100644 --- a/python/plugins/processing/algs/gdal/warp.py +++ b/python/plugins/processing/algs/gdal/warp.py @@ -31,6 +31,7 @@ from PyQt.QtGui import QIcon from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm from processing.core.parameters import ParameterRaster +from processing.core.parameters import ParameterExtent from processing.core.parameters import ParameterSelection from processing.core.parameters import ParameterCrs from processing.core.parameters import ParameterNumber @@ -64,6 +65,7 @@ class warp(GdalAlgorithm): BIGTIFFTYPE = ['', 'YES', 'NO', 'IF_NEEDED', 'IF_SAFER'] COMPRESSTYPE = ['NONE', 'JPEG', 'LZW', 'PACKBITS', 'DEFLATE'] TFW = 'TFW' + RAST_EXT = 'RAST_EXT' def getIcon(self): return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'warp.png')) @@ -84,6 +86,7 @@ class warp(GdalAlgorithm): 0.0, None, 0.0)) self.addParameter(ParameterSelection(self.METHOD, self.tr('Resampling method'), self.METHOD_OPTIONS)) + self.addParameter(ParameterExtent(self.RAST_EXT, self.tr('Raster extent'))) params = [] params.append(ParameterSelection(self.RTYPE, @@ -125,7 +128,8 @@ class warp(GdalAlgorithm): compress = self.COMPRESSTYPE[self.getParameterValue(self.COMPRESS)] bigtiff = self.BIGTIFFTYPE[self.getParameterValue(self.BIGTIFF)] tfw = unicode(self.getParameterValue(self.TFW)) - + rastext = unicode(self.getParameterValue(self.RAST_EXT)) + arguments = [] arguments.append('-ot') arguments.append(self.TYPE[self.getParameterValue(self.RTYPE)]) @@ -149,6 +153,18 @@ class warp(GdalAlgorithm): arguments.append(unicode(self.getParameterValue(self.TR))) arguments.append(unicode(self.getParameterValue(self.TR))) extra = unicode(self.getParameterValue(self.EXTRA)) + regionCoords = rastext.split(',') + try: + rastext = [] + rastext.append('-te') + rastext.append(regionCoords[0]) + rastext.append(regionCoords[2]) + rastext.append(regionCoords[1]) + rastext.append(regionCoords[3]) + except IndexError: + rastext = [] + if rastext: + arguments.extend(rastext) if len(extra) > 0: arguments.append(extra) if GdalUtils.getFormatShortNameFromFilename(out) == "GTiff":