Skip to content
Permalink
Browse files

[processing] add "-te_srs" option to gdal_warp (fix #15033)

  • Loading branch information
alexbruy committed Jun 22, 2016
1 parent d69ec2e commit b9b8d37cc0b4c80ee50b4cc29b140262bf470354
Showing with 18 additions and 0 deletions.
  1. +7 −0 python/plugins/processing/algs/gdal/GdalUtils.py
  2. +11 −0 python/plugins/processing/algs/gdal/warp.py
@@ -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
@@ -175,3 +178,7 @@ def escapeAndJoin(strList):
escaped = s
joined += escaped + ' '
return joined.strip()

@staticmethod
def version():
return int(gdal.VersionInfo('VERSION_NUM'))
@@ -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'))
@@ -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))
@@ -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')
@@ -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":

0 comments on commit b9b8d37

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