Skip to content

Commit

Permalink
[processing] fix gdalwarp handling of custom projection for target ex…
Browse files Browse the repository at this point in the history
…tent

Fixes #31276

(cherry picked from commit 283c8b8)
  • Loading branch information
gkimbell authored and nyalldawson committed Sep 9, 2019
1 parent da3272e commit 19b5ac8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/gdal/warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(extent.yMaximum())

extentCrs = self.parameterAsCrs(parameters, self.TARGET_EXTENT_CRS, context)
if extentCrs:
if extentCrs.isValid():
arguments.append('-te_srs')
arguments.append(extentCrs.authid())
arguments.append(GdalUtils.gdal_crs_string(extentCrs))

if self.parameterAsBool(parameters, self.MULTITHREADING, context):
arguments.append('-multi')
Expand Down
14 changes: 14 additions & 0 deletions python/plugins/processing/tests/GdalAlgorithmsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2217,6 +2217,20 @@ def testWarp(self):
source + ' ' +
outdir + '/check.jpg'])

# with target using custom projection and user-defined extent
custom_crs2 = 'proj4: +proj=longlat +a=6378388 +b=6356912 +no_defs'
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'SOURCE_CRS': custom_crs2,
'TARGET_CRS': custom_crs2,
'TARGET_EXTENT': '18.67,18.70,45.78,45.81',
'TARGET_EXTENT_CRS': custom_crs2,
'OUTPUT': outdir + '/check.tif'}, context, feedback),
['gdalwarp',
'-s_srs "+proj=longlat +a=6378388 +b=6356912 +no_defs" -t_srs "+proj=longlat +a=6378388 +b=6356912 +no_defs" -r near -te 18.67 45.78 18.7 45.81 -te_srs "+proj=longlat +a=6378388 +b=6356912 +no_defs" -of GTiff ' +
source + ' ' +
outdir + '/check.tif'])

# with non-EPSG crs code
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
Expand Down

0 comments on commit 19b5ac8

Please sign in to comment.