[Gdal-dev] How to best perform raster cell aggregation

Frank Warmerdam warmerdam at pobox.com
Mon Feb 12 20:01:59 EST 2007


Chase, Andrew wrote:
> Hi Folks,
> 
> I'm working with raster files, starting in the NetCDF format, but then 
> moving them to .tif and .png based on how the user will need to 
> manipulate them. One seemingly simple thing that I've been unable to 
> find a simple solution for is resampling the data with an aggregation 
> algorithm. For instance, I'd like to go from a 10 meter cell size to a 
> 100 meter cell size where the value for a 100m cell is the sum of all 
> the 10m cells that the 100m cell now represents. I have a very sparsely 
> populated dataset, so averaging on resample tends to just push 
> everything towards zero. What I'm looking for is the ability to see 
> where very small data points exist when zoomed out.
> 
> I thought gdaladdo would be a good option for this, but it looks like is 
> only for adding overview's to an already existing file and not for 
> creating new files. Could I add an overlay to a tif and then extract 
> just that overlay image into, say, a png?

Andrew,

You can use gdaladdo to add overviews, and then use dumpoverviews to
dump the overviews to separate files.   You will likely have to
build dumpoverviews manually by going into gdal/apps and doing "make
dumpoverviews".

However, this won't give you the summed values you seem to want.

I'd suggest looking into righting a summing downsampler as a python
script using numpy to do the computation.  It may be a bit of fiddling
around.

Good luck,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org




More information about the Gdal-dev mailing list