Skip to content

Commit d95e884

Browse files
gkimbellnyalldawson
authored andcommittedSep 8, 2019
[processing] fix gdalwarp handling of custom projection for target extent
Fixes #31276 (cherry picked from commit 283c8b8)
1 parent c451714 commit d95e884

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed
 

‎python/plugins/processing/algs/gdal/warp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
215215
arguments.append(extent.yMaximum())
216216

217217
extentCrs = self.parameterAsCrs(parameters, self.TARGET_EXTENT_CRS, context)
218-
if extentCrs:
218+
if extentCrs.isValid():
219219
arguments.append('-te_srs')
220-
arguments.append(extentCrs.authid())
220+
arguments.append(GdalUtils.gdal_crs_string(extentCrs))
221221

222222
if self.parameterAsBoolean(parameters, self.MULTITHREADING, context):
223223
arguments.append('-multi')

‎python/plugins/processing/tests/GdalAlgorithmsTest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2225,6 +2225,20 @@ def testWarp(self):
22252225
source + ' ' +
22262226
outdir + '/check.jpg'])
22272227

2228+
# with target using custom projection and user-defined extent
2229+
custom_crs2 = 'proj4: +proj=longlat +a=6378388 +b=6356912 +no_defs'
2230+
self.assertEqual(
2231+
alg.getConsoleCommands({'INPUT': source,
2232+
'SOURCE_CRS': custom_crs2,
2233+
'TARGET_CRS': custom_crs2,
2234+
'TARGET_EXTENT': '18.67,18.70,45.78,45.81',
2235+
'TARGET_EXTENT_CRS': custom_crs2,
2236+
'OUTPUT': outdir + '/check.tif'}, context, feedback),
2237+
['gdalwarp',
2238+
'-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 ' +
2239+
source + ' ' +
2240+
outdir + '/check.tif'])
2241+
22282242
# with non-EPSG crs code
22292243
self.assertEqual(
22302244
alg.getConsoleCommands({'INPUT': source,

0 commit comments

Comments
 (0)
Please sign in to comment.