[Qgis-user] Clip Raster by Mask Layer algorithm not working when part of processing model

Phil Ribbens philip.ribbens at gmail.com
Tue Apr 17 13:03:00 PDT 2018


Hi,

I'm trying to include the “Clip raster by mask layer” algorithm in a processing model, but I can’t get it to work. What’s weird is that when I run the algorithm by itself (i.e. not as part of a model), it works fine.

Below are the logs of each (when I run it by itself and when I run it as part of a model). From studying these it seems like the only difference (and what seems to be causing the problem) is that when the algorithm is run from within a model the path to the MASK layer isn’t being included in the GDAL command. Anybody have any idea why? Am I doing something wrong? Is it a bug? 

Thanks,
Phil Ribbens


Running Clip raster by mask layer by itself (works fine)
Processing algorithm…
AlgorithmDialog
Input parameters:
{ 'INPUT' : '/var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_c893e43e9931410397ab42a423fd9d61/e27038e2ea2f4b42842aaacf3c6bf15c/OUTPUT.tif', 'MASK' : '/Users/philipribbens/Dropbox/work/QGIS plugin for Key-Log/lower_roanoke_subbasin.shp', 'NODATA' : 255, 'ALPHA_BAND' : False, 'CROP_TO_CUTLINE' : True, 'KEEP_RESOLUTION' : False, 'OPTIONS' : '', 'DATA_TYPE' : 0, 'OUTPUT' : '/var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_6c6a3f6013994c2eafbaf28a231297a3/44f299a602e34ef8a666e6848ff95658/OUTPUT.tif' }

GDAL command:
gdalwarp -ot Byte -of GTiff -cutline "/Users/philipribbens/Dropbox/work/QGIS plugin for Key-Log/lower_roanoke_subbasin.shp" -crop_to_cutline -dstnodata 255.0 /var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_c893e43e9931410397ab42a423fd9d61/e27038e2ea2f4b42842aaacf3c6bf15c/OUTPUT.tif /var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_6c6a3f6013994c2eafbaf28a231297a3/44f299a602e34ef8a666e6848ff95658/OUTPUT.tif
GDAL command output:
Copying color table from /var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_c893e43e9931410397ab42a423fd9d61/e27038e2ea2f4b42842aaacf3c6bf15c/OUTPUT.tif to new file. 
Creating output file that is 3642P x 2860L. 
Processing input file /var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_c893e43e9931410397ab42a423fd9d61/e27038e2ea2f4b42842aaacf3c6bf15c/OUTPUT.tif. 
Using internal nodata values (e.g. 255) for image /var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_c893e43e9931410397ab42a423fd9d61/e27038e2ea2f4b42842aaacf3c6bf15c/OUTPUT.tif. 
0...10...20...30...40...50...60...70...80...90...100 - done. 
Execution completed in 0.65 seconds
Results:
{'OUTPUT': <QgsProcessingOutputLayerDefinition {'sink':/var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_6c6a3f6013994c2eafbaf28a231297a3/44f299a602e34ef8a666e6848ff95658/OUTPUT.tif, 'createOptions': {'fileEncoding': 'System'}}>}

Loading resulting layers
Algorithm 'Clip raster by mask layer' finished



Running Clip raster by mask layer as part of a model (doesn’t work)
Processing algorithm…
AlgorithmDialog
Input parameters:
{ 'inputrasterlayer' : '/var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_c893e43e9931410397ab42a423fd9d61/e27038e2ea2f4b42842aaacf3c6bf15c/OUTPUT.tif', 'maskvectorlayer' : '/Users/philipribbens/Dropbox/work/QGIS plugin for Key-Log/lower_roanoke_subbasin.shp', 'gdal:cliprasterbymasklayer_1:Final clipped raster' : '/var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_6c6a3f6013994c2eafbaf28a231297a3/3b9e2df02eca4aa6b8f6476df78cdf9f/gdal:cliprasterbymasklayer_1:Final clipped raster.tif' }

Prepare algorithm: gdal:cliprasterbymasklayer_1
Running Clip raster by mask layer [1/1]
Input Parameters:
{ ALPHA_BAND: False, CROP_TO_CUTLINE: True, DATA_TYPE: 0, INPUT: '/var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_c893e43e9931410397ab42a423fd9d61/e27038e2ea2f4b42842aaacf3c6bf15c/OUTPUT.tif', KEEP_RESOLUTION: False, MASK: '/Users/philipribbens/Dropbox/work/QGIS plugin for Key-Log/lower_roanoke_subbasin.shp', NODATA: 255, OPTIONS: '', OUTPUT: '/var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_6c6a3f6013994c2eafbaf28a231297a3/3b9e2df02eca4aa6b8f6476df78cdf9f/gdal:cliprasterbymasklayer_1:Final clipped raster.tif' }
GDAL command:
gdalwarp -ot Byte -of GTiff -cutline -crop_to_cutline -dstnodata 255.0 /var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_c893e43e9931410397ab42a423fd9d61/e27038e2ea2f4b42842aaacf3c6bf15c/OUTPUT.tif "/var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_6c6a3f6013994c2eafbaf28a231297a3/3b9e2df02eca4aa6b8f6476df78cdf9f/gdal:cliprasterbymasklayer_1:Final clipped raster.tif"
GDAL command output:
ERROR 1: Cannot open -crop_to_cutline. 
OK. Execution took 0.196 s (1 outputs).
Model processed OK. Executed 1 algorithms total in 0.372 s.
Execution completed in 0.41 seconds
Results:
{'gdal:cliprasterbymasklayer_1:Final clipped raster': <QgsProcessingOutputLayerDefinition {'sink':/var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_6c6a3f6013994c2eafbaf28a231297a3/3b9e2df02eca4aa6b8f6476df78cdf9f/gdal:cliprasterbymasklayer_1:Final clipped raster.tif, 'createOptions': {'fileEncoding': 'System'}}>}

Loading resulting layers
The following layers were not correctly generated.
/var/folders/10/qfg4mkl127gcxgmpr82tl1xc0000gq/T/processing_6c6a3f6013994c2eafbaf28a231297a3/3b9e2df02eca4aa6b8f6476df78cdf9f/gdal:cliprasterbymasklayer_1:Final clipped raster.tif
You can check the 'Log Messages Panel' in QGIS main window to find more information about the execution of the algorithm.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20180417/fc80fb1c/attachment.html>


More information about the Qgis-user mailing list