Skip to content

Commit

Permalink
Merge pull request #2893 from NaturalGIS/processing_gdalwarp_extent
Browse files Browse the repository at this point in the history
processing: add extent parameter to gdal_warp
  • Loading branch information
volaya committed Mar 23, 2016
2 parents 48104d5 + b073111 commit d808ef9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion python/plugins/processing/algs/gdal/warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

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
Expand Down Expand Up @@ -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'))
Expand All @@ -84,6 +86,7 @@ def defineCharacteristics(self):
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,
Expand Down Expand Up @@ -125,7 +128,8 @@ def getConsoleCommands(self):
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)])
Expand All @@ -149,6 +153,18 @@ def getConsoleCommands(self):
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":
Expand Down

0 comments on commit d808ef9

Please sign in to comment.