[GRASSLIST:3583] Re: How to resample and get a max value?

Terry Duell tduell at planet.net.au
Wed Apr 24 23:57:43 EDT 2002


Glynn Clements wrote:
> 
> Terry Duell wrote:
> 
> > > > I have an interesting problem which one of you more experienced GRASS
> > > > users may have the answer to.
> > > > I want to resample a raster map to a lower resolution (eg 100m down to
> > > > 1000m), but in doing so I want to use the max value in the 100m raster
> > > > within the boundaries of each 1000m cell.
> > > > I have a suspicion that r.mapcalc might be the only way...but the 'how
> > >
> > > Maybe r.neighbors is what you're after?
> >
> >  Ah. Indeed, it does look like it might do the trick. The man page does
> > seem to frown upon generating a raster which doesn't have the same
> > resolution as the input. I guess I'll have to try and see.
> 
> Actually, I doubt that r.neighbors will do what you require. Each
> cell in the output map is based upon a "window" of cells surrounding
> the corresponding cell in the input.
> 
> Note that the resolution of input and output are always the same. The
> presence or absence of the "-a" flag simply controls whether the
> resolution is taken from the input map (without "-a"), or the current
> region (with "-a").
> 
> IOW, omitting "-a" just causes the resolution to be changed to that of
> the input map for the duration of the command. Without "-a", the input
> will be resampled according to the current resolution (this is how
> most r.* commands normally behave).
> 
> AFAICT, what you need is a cross between r.resample/r.resamp.rst and
> r.neighbors, i.e. a resampling program with more options as to how to
> compute the resulting pixel. As there isn't such a program at present,
> you would either need to modify an existing program, or use r.mapcalc
> followed by r.resample.

Thanks for that advice. 
I did try r.neighbours with a 9x9 window and the result looked about
what I expected I should get, but given what you have said above, I need
to rethink!

Regards,
Terry Duell



More information about the grass-user mailing list