1

I have had used gdalogr:cliprasterbymasklayer function in PyQGIS many times before but with the latest update there seems to be a lot more extra arguments and I can't figure out how to get the algorithm to function properly anymore.

processing.alghelp('gdalogr:cliprasterbymasklayer') returns the following:

ALGORITHM: Clip raster by mask layer
INPUT < ParameterRaster>
MASK < ParameterVector>
NO_DATA < ParameterString>
ALPHA_BAND < ParameterBoolean>
CROP_TO_CUTLINE < ParameterBoolean> KEEP_RESOLUTION < ParameterBoolean>
RTYPE < ParameterSelection> COMPRESS < ParameterSelection>
JPEGCOMPRESSION < ParameterNumber> ZLEVEL < ParameterNumber>
PREDICTOR < ParameterNumber>
TILED < ParameterBoolean>
BIGTIFF < ParameterSelection>
TFW < ParameterBoolean>
EXTRA < ParameterString>
OUTPUT < OutputRaster>

RTYPE(Output raster type) 0 - Byte 1 - Int16 2 - UInt16 3 - UInt32 4 - Int32 5 - Float32 6 - Float64

COMPRESS(GeoTIFF options. Compression type:) 0 - NONE 1 - JPEG 2 - LZW 3 - PACKBITS 4 - DEFLATE

BIGTIFF(Control whether the created file is a BigTIFF or a classic TIFF) 0 - 1 - YES 2 - NO 3 - IF_NEEDED 4 - IF_SAFER


Are 16 options really needed to clip a raster? Is there a simpler option via Python? I need it for batch processing.

My best attempt got an output, but there is nothing in the file. processing.runalg('gdalogr:cliprasterbymasklayer', rstrData, shp, 'none', False, True, True, 1, 1, 1, 1, 1, True, 0, True, "", rstrOutput+str(rstrData))

Can anyone explain to me where I'm going wrong please?

https://docs.qgis.org/2.6/en/docs/user_manual/processing_algs/gdalogr/gdal_extraction/cliprasterbymasklayer.html

Docs are out of date to reflect this new algorithm.

Last version was a lot easier to control.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.