[GRASS-user] Raster aggregation with r.neighbors

Patrick Meyfroidt meyfroidt at geog.ucl.ac.be
Tue Jan 30 03:13:24 EST 2007


Thank you for all your advices,

I used also the r.statistics method, but it was very time-consuming 
to create a base raster map at the desired resolution (I foudn a 
procedure here in the archive: creating two grids in a spreadsheet 
editor, one with cell value being the x-coordinate, and the other 
with cell value being the y-coordinate, and then combine them). And 
if I want to make tests with other resolutions (say, 6, 7, 8 km 
instead of 5 km), I need to re-do the same long procedure.

Is there a simple and fast way to create a raster map with unique 
cell values (one category for each cell)? With some r.mapcalc trick?

(I will switch to r.resamp.stats as soon as I can, but I need to 
understand this CVS-thing...)

Thank you,

Patrick




At 02:35 27/01/2007, Glynn Clements wrote:

>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