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.

1 Answer 1


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)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.