[GRASSLIST:585] Re: Change of spatial support

Glynn Clements glynn at gclements.plus.com
Wed Apr 5 15:43:51 EDT 2006


Ulrich Leopold wrote:

> r.resamp.rst does a re-interpolation of the raster cells. I am  looking for an
> aggregation of floating point raster cells for a lower grid resolution (4x4 =>
> 1x1). Simply take the average of a 4 x 4 raster cells and produce a single
> mean value for a larger grid cell (but for floating point numbers not
> integers).
> 
> Take 4 x 4 raster cells
> 
> 2.5  3.5  1.5  0.5
> 2.5  3.5  1.5  0.5
> 2.5  3.5  1.5  0.5
> 2.5  3.5  1.5  0.5
> 
> compute the mean and variance to yield one raster cell with
> 
> mean = 2.0
> var  = 1.333
> 
> jump to next block of 4 x 4 raster cells which have not been used in previous
> calculation and repeat the calculation and so on.
> 
> Any ideas for r.mapcalc?

Create a base map where each 4x4 block has a unique category then use
r.average. E.g.

	r.mapcalc 'base = eval(i = (row() - 1)/4, j = (col() - 1)/4, (i+j) * (i+j+1) / 2 + j)'
	r.average base=base cover=inmap out=outmap

Reduce the region resolution by 4 then use r.resample.

Unfortunately, the r.average step is rather slow.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-user mailing list