[gdal-dev] help with resampling via python
Klokan Petr Přidal
klokan at klokan.cz
Wed Apr 1 07:57:26 EDT 2009
You have two options in GDAL API for resampling via Python:
gdal.RegenerateOverview() with 'average' and 'mode' algorithms.
gdal.ReprojectImage() with 'bilinear','cubic','cubicspline' and
Example of such functionality is in gdal2tiles.py in function
I am resampling in memory (because I am working only with small tiles
with usual size 256x256px):
mem_drv = gdal.GetDriverByName( 'MEM' )
target = mem_drv.Create('', outputXsize, outputYsize, bands)
I think gdal.ReprojectImage() would be able to rescale also into VRT dataset.
Another choice is to create copy into the VRT dataset and change the
target raster size in XML attributes manually in the text.
In that case the average algorithm in VRT is exposed by the
2009/4/1 Chris Somerlot <csomerlot at gmail.com>:
> Having trouble figuring out how to resample an image to a different cell
> size from python. I looked over the VRT driver page and have been trying to
> get this to work:
> from osgeo import gdal
> src = gdal.Open('DOQ_test.TIF')
> drv = gdal.GetDriverByName('VRT')
> dst = drv.CreateCopy("", src, 0)
> dst.RasterXSize = '125'
> But it seems the cell size in the datasets and the bands are read only? Is
> there any programmatic way to do this?
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
More information about the gdal-dev