[QGIS-Developer] Handling different GDAL versions in PyQGIS

Tom Chadwin tom.chadwin at nnpa.org.uk
Tue May 9 10:45:17 PDT 2017


Hello all

An issue I face is different users' different GDAL versions meaning making
Processing GDAL calls in a plugin difficult, as you have to get the
arguments right:

https://github.com/tomchadwin/qgis2web/blob/v2.17.0/utils.py#L314

I've got these different argument lists wrapped in try: blocks, but was
wondering if a different approach might be better. If I call, for example,
processing.runalg("gdalogr:warpreproject") without arguments from the
console, I get an error back:

Error: Wrong number of parameters
ALGORITHM: Warp (reproject)
	INPUT <ParameterRaster>
	SOURCE_SRS <ParameterCrs>
	DEST_SRS <ParameterCrs>
	NO_DATA <ParameterString>
	TR <ParameterNumber>
	METHOD <ParameterSelection>
	RAST_EXT <ParameterExtent>
	EXT_CRS <ParameterCrs>
	RTYPE <ParameterSelection>
	COMPRESS <ParameterSelection>
	JPEGCOMPRESSION <ParameterNumber>
	ZLEVEL <ParameterNumber>
	PREDICTOR <ParameterNumber>
	TILED <ParameterBoolean>
	BIGTIFF <ParameterSelection>
	TFW <ParameterBoolean>
	EXTRA <ParameterString>
	OUTPUT <OutputRaster>


METHOD(Resampling method)
	0 - near
	1 - bilinear
	2 - cubic
	3 - cubicspline
	4 - lanczos
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

Can I rely on getting this kind of output from all GDAL versions? If so, I
can try to figure out the best way to parse out the arguments it needs, and
supply them.

Should this work?

Thanks

Tom



-----
Buy Pie Spy: Adventures in British pastry 2010-11 on Amazon 
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Handling-different-GDAL-versions-in-PyQGIS-tp5319952.html
Sent from the QGIS - Developer mailing list archive at Nabble.com.


More information about the QGIS-Developer mailing list