I would like to resample a raster to multiple rasters of a certain amount of pixels in width and height based on a bilinear resampling method.
However, I am not sure if the available syntax allows to do this from the QGIS Python console.
This works fine:
processing.runalg('gdalogr:translate',{"INPUT":rlayer, "OUTSIZE":j, "OUTSIZE_PERC":False, "EXPAND":0, "PROJWIN":"%f,%f,%f,%f" % (xmin, xmax, ymin, ymax), "OUTPUT":resampled})
For the snipped above the default resample method (nearest neighbor) is used. According to the gdal manual, the method can be changed with the -r flag, but from processing.alghelp("gdalogr:translate"), this option seems to be unavailable.
Therefore, I thought of using gdalogr:warpreproject instead, where the resampling method can be defined. However, now I cannot define the amount of pixels in width and height as indicated in the gdal manual, because the TS flag is not available according to processing.alghelp("gdalogr:warpreproject").
Optimal would be something like:
processing.runalg('gdalogr:warpreproject',{"INPUT":rlayer, "METHOD":1, "RAST_EXT":"%f,%f,%f,%f" % (xmin, xmax, ymin, ymax),"TS":"%i,%i" % (j, j), "OUTPUT":resampled})
Does anyone know how to solve this?
extra
parameter of those algorithms?extra
parameter andgdal.Translate()
parameters in PyQGIS. Could you provide a short example?