Skip to content

Commit

Permalink
[processing] add "-te_srs" option to gdal_warp (fix #15033)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Jun 22, 2016
1 parent d69ec2e commit b9b8d37
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/plugins/processing/algs/gdal/GdalUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import os
import subprocess
import platform

from osgeo import gdal

from qgis.PyQt.QtCore import QSettings
from qgis.core import QgsApplication, QgsVectorFileWriter
from processing.core.ProcessingLog import ProcessingLog
Expand Down Expand Up @@ -175,3 +178,7 @@ def escapeAndJoin(strList):
escaped = s
joined += escaped + ' '
return joined.strip()

@staticmethod
def version():
return int(gdal.VersionInfo('VERSION_NUM'))
11 changes: 11 additions & 0 deletions python/plugins/processing/algs/gdal/warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class warp(GdalAlgorithm):
COMPRESSTYPE = ['NONE', 'JPEG', 'LZW', 'PACKBITS', 'DEFLATE']
TFW = 'TFW'
RAST_EXT = 'RAST_EXT'
EXT_CRS = 'EXT_CRS'

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'warp.png'))
Expand All @@ -88,6 +89,10 @@ def defineCharacteristics(self):
self.tr('Resampling method'), self.METHOD_OPTIONS))
self.addParameter(ParameterExtent(self.RAST_EXT, self.tr('Raster extent')))

if GdalUtils.version() > 2000000:
self.addParameter(ParameterCrs(self.EXT_CRS,
self.tr('CRS of the raster extent'), ''))

params = []
params.append(ParameterSelection(self.RTYPE,
self.tr('Output raster type'), self.TYPE, 5))
Expand Down Expand Up @@ -131,6 +136,7 @@ def getConsoleCommands(self):
bigtiff = self.BIGTIFFTYPE[self.getParameterValue(self.BIGTIFF)]
tfw = unicode(self.getParameterValue(self.TFW))
rastext = unicode(self.getParameterValue(self.RAST_EXT))
rastext_crs = self.getParameterValue(self.EXT_CRS)

arguments = []
arguments.append('-ot')
Expand Down Expand Up @@ -169,6 +175,11 @@ def getConsoleCommands(self):
rastext = []
if rastext:
arguments.extend(rastext)

if rastext and len(rastext_crs) > 0:
arguments.append('-te_srs')
arguments.append(rastext_crs)

if extra and len(extra) > 0:
arguments.append(extra)
if GdalUtils.getFormatShortNameFromFilename(out) == "GTiff":
Expand Down

0 comments on commit b9b8d37

Please sign in to comment.