I have a single-band geo-referenced raster image (a DEM) and my goal is to increase the number of pixels in each dimension (x and y) by 3.
So given an initial resolution of 1200 * 1200 pixels, I want to upsample it to 3600 * 3600 pixels, keeping the geographic referencing.
This procedure is a part of a large batch processing so simple gui workflow is not an option and I'd like to do it programmatically, using python gdal
.
What is the right way to do it and is there any interpolation required to do it?
Best Answer
The following
gdal
script is useful to resample an image to a smaller pixel size:However, this script does not perform a specific interpolation and the result will look similar to the following picture (with a different resampling size):
Note: image taken from Geoprocessing with Python (by Chris Garrard) book. https://www.manning.com/books/geoprocessing-with-python
Furthermore, you could try using
gdal_translate
from thegdal
command line utilities. (More info here: http://www.gdal.org/gdal_translate.html)As you need to do a large processing batch it is possible to use python along with this utility as the following example:
where:
- of
specifies the output format.-outsize
specifies the output size in pixels (xsize, ysize)-r
specifies the resampling algorithmraster.tif
is the input filenameraster_resample.tif
is the output filename.