[GIS] Raster interpolation with gdalwarp, and replicating with python API

gdalgdalwarpinterpolationpython

My problem is similar to this: Replicating result of gdalwarp using gdal Python bindings. I want to resample a raster using bilinear interpolation, which I've done successfully with gdalwarp by adding height and width specifications for the output file:

gdalwarp -ts w_output h_output -r bilinear -co 'TFW=YES' -of VRT input.tif output.vrt

I'm trying to replicate the above result using the Python API. Can it be done using gdal.AutoCreateWarpedVRT?

src_ds = gdal.Open(input.tif)
src_wkt = None
dst_wkt = ????
resampling = gdal.GRA_Bilinear
output_vrt = gdal.AutoCreateWarpedVRT(src_ds, src_wkt, dst_wkt, resampling)

I'm guessing I have to do something clever with the dst_wkt in order to replicate the above gdalwarp result. I just want to increase the number of pixels by a factor of 10 compared to the input raster.

P.S. If it's better to just use gdalwarp, that's good to know. I have no problem doing that.

Best Answer

You have now a better way to do.

Since RFC 59.1 : GDAL/OGR utilities as a library, you can use gdalwarp from Python directly without using any call to the command line utility but using really the function from Python.

This solution is a bit "on the edge" as you need at the moment to use the latest GDAL version (version 2.1, in fact the master/trunk version)