Skip to content

Commit

Permalink
Merge pull request #30715 from alexbruy/gdal-layers
Browse files Browse the repository at this point in the history
[processing] pass layer name to the gdalwarp to avoid issues with multi-layer datasources (fix #30292)
  • Loading branch information
alexbruy committed Jul 18, 2019
2 parents 4bab91c + 109d1fb commit d0b8d62
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions python/plugins/processing/algs/gdal/ClipRasterByMask.py
Expand Up @@ -217,6 +217,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):

arguments.append('-cutline')
arguments.append(maskLayer)
arguments.append('-cl')
arguments.append(maskLayerName)

if self.parameterAsBoolean(parameters, self.CROP_TO_CUTLINE, context):
arguments.append('-crop_to_cutline')
Expand Down
12 changes: 6 additions & 6 deletions python/plugins/processing/tests/GdalAlgorithmsRasterTest.py
Expand Up @@ -343,7 +343,7 @@ def testClipRasterByMask(self):
'OUTPUT': outdir + '/check.jpg'}, context, feedback),
['gdalwarp',
'-of JPEG -cutline ' +
mask + ' -crop_to_cutline ' + source + ' ' +
mask + ' -cl polys2 -crop_to_cutline ' + source + ' ' +
outdir + '/check.jpg'])
# with NODATA value
self.assertEqual(
Expand All @@ -353,7 +353,7 @@ def testClipRasterByMask(self):
'OUTPUT': outdir + '/check.jpg'}, context, feedback),
['gdalwarp',
'-of JPEG -cutline ' +
mask + ' -crop_to_cutline -dstnodata 9999.0 ' + source + ' ' +
mask + ' -cl polys2 -crop_to_cutline -dstnodata 9999.0 ' + source + ' ' +
outdir + '/check.jpg'])
# with "0" NODATA value
self.assertEqual(
Expand All @@ -363,7 +363,7 @@ def testClipRasterByMask(self):
'OUTPUT': outdir + '/check.jpg'}, context, feedback),
['gdalwarp',
'-of JPEG -cutline ' +
mask + ' -crop_to_cutline -dstnodata 0.0 ' + source + ' ' +
mask + ' -cl polys2 -crop_to_cutline -dstnodata 0.0 ' + source + ' ' +
outdir + '/check.jpg'])
# with "0" NODATA value and custom data type
self.assertEqual(
Expand All @@ -374,7 +374,7 @@ def testClipRasterByMask(self):
'OUTPUT': outdir + '/check.jpg'}, context, feedback),
['gdalwarp',
'-ot Float32 -of JPEG -cutline ' +
mask + ' -crop_to_cutline -dstnodata 0.0 ' + source + ' ' +
mask + ' -cl polys2 -crop_to_cutline -dstnodata 0.0 ' + source + ' ' +
outdir + '/check.jpg'])
# with creation options
self.assertEqual(
Expand All @@ -384,7 +384,7 @@ def testClipRasterByMask(self):
'OUTPUT': outdir + '/check.jpg'}, context, feedback),
['gdalwarp',
'-of JPEG -cutline ' +
mask + ' -crop_to_cutline -co COMPRESS=DEFLATE -co PREDICTOR=2 -co ZLEVEL=9 ' +
mask + ' -cl polys2 -crop_to_cutline -co COMPRESS=DEFLATE -co PREDICTOR=2 -co ZLEVEL=9 ' +
source + ' ' +
outdir + '/check.jpg'])
# with multothreading and additional parameters
Expand All @@ -396,7 +396,7 @@ def testClipRasterByMask(self):
'OUTPUT': outdir + '/check.jpg'}, context, feedback),
['gdalwarp',
'-of JPEG -cutline ' +
mask + ' -crop_to_cutline -multi -nosrcalpha -wm 2048 -nomd ' +
mask + ' -cl polys2 -crop_to_cutline -multi -nosrcalpha -wm 2048 -nomd ' +
source + ' ' +
outdir + '/check.jpg'])

Expand Down

0 comments on commit d0b8d62

Please sign in to comment.