That was the other method I was trying, reading the VRT file into memory using the new (to me) xml.etree.ElementTree lib. I was missing the <AveragedSource> tag, though, thanks.<br><br><div class="gmail_quote">2009/4/1 Klokan Petr Pĝidal <span dir="ltr"><<a href="mailto:klokan@klokan.cz">klokan@klokan.cz</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Chris,<br>
<br>
You have two options in GDAL API for resampling via Python:<br>
<br>
gdal.RegenerateOverview() with 'average' and 'mode' algorithms.<br>
and<br>
gdal.ReprojectImage() with 'bilinear','cubic','cubicspline' and<br>
'lanczos' algorithms.<br>
<br>
Example of such functionality is in gdal2tiles.py in function<br>
GDAL2Tiles.scale_query_to_tile():<br>
<a href="http://code.google.com/p/maptiler/source/browse/trunk/maptiler/gdal2tiles.py#1433" target="_blank">http://code.google.com/p/maptiler/source/browse/trunk/maptiler/gdal2tiles.py#1433</a><br>
<br>
I am resampling in memory (because I am working only with small tiles<br>
with usual size 256x256px):<br>
<br>
mem_drv = gdal.GetDriverByName( 'MEM' )<br>
target = mem_drv.Create('', outputXsize, outputYsize, bands)<br>
<br>
I think gdal.ReprojectImage() would be able to rescale also into VRT dataset.<br>
<br>
Another choice is to create copy into the VRT dataset and change the<br>
target raster size in XML attributes manually in the text.<br>
In that case the average algorithm in VRT is exposed by the<br>
<AveragedSource> tag...<br>
<br>
Best,<br>
<br>
Klokan<br>
<br>
2009/4/1 Chris Somerlot <<a href="mailto:csomerlot@gmail.com">csomerlot@gmail.com</a>>:<br>
<div><div></div><div class="h5">> Having trouble figuring out how to resample an image to a different cell<br>
> size from python. I looked over the VRT driver page and have been trying to<br>
> get this to work:<br>
><br>
> from osgeo import gdal<br>
><br>
> gdal.AllRegister()<br>
><br>
> src = gdal.Open('DOQ_test.TIF')<br>
> drv = gdal.GetDriverByName('VRT')<br>
> dst = drv.CreateCopy("", src, 0)<br>
><br>
> dst.RasterXSize = '125'<br>
><br>
> But it seems the cell size in the datasets and the bands are read only? Is<br>
> there any programmatic way to do this?<br>
><br>
</div></div>> _______________________________________________<br>
> gdal-dev mailing list<br>
> <a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
><br>
<font color="#888888"><br>
--<br>
<a href="http://blog.klokan.cz/" target="_blank">http://blog.klokan.cz/</a><br>
<a href="http://www.maptiler.org/" target="_blank">http://www.maptiler.org/</a><br>
<a href="http://www.oldmapsonline.org/" target="_blank">http://www.oldmapsonline.org/</a><br>
</font></blockquote></div><br>