[GRASS-user] Raster aggregation with r.neighbors

Glynn Clements glynn at gclements.plus.com
Fri Jan 26 20:35:12 EST 2007


Patrick Meyfroidt wrote:

> I'm working with grass 6.2.1 and I'm looking for a way to aggregate a 
> raster (downscale the resolution from 1km to 5km by calculating the 
> average of values over a 5x5 pixels window). It seems that 
> r.resamp.stats is designed for that, but it is not in version 6.2.1
> So I used r.neighbors like that:
> 
>  > g.region res=5000
>  > r.neighbors -a input=xxx output=xxx method=average size=5
> 
> In the archive I found that:
> http://grass.itc.it/pipermail/grassuser/2002-September/007417.html
> but using the -a option seemed to solve the problem of output resolution.
> 
> Can anyone tell me if this method could be problematic in some way, 
> or provide less performant results than r.resample.stats?

Both the r.statistics and r.neighbors approaches work, but have some
drawbacks.

r.statistics requires that you first create a suitable base map (with
one category for each output cell), and doesn't work well with
floating-point data.

r.neighbors is significantly slower than r.resamp.stats (e.g. for a
5x5 scaling, it will calculate the aggregate for all 25 cells, then
the resampling step discards all but one of them). Also, you are
limited to odd window sizes (3x3, 5x5, 7x7 etc).

Also, both involve several steps: set region to source resolution,
compute aggregate, set region to target resolution, resample. 

r.resamp.stats does the same thing with a single command, and isn't
limited to odd window sizes (or even to a fixed size; it will work
correctly where the scale factor isn't an integer).

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




More information about the grass-user mailing list