[GRASS-user] GRASS64 - r.mapcalc - replacement of specifics value by a mean of nearest neigbour

Nikos Alexandris nik at nikosalexandris.net
Mon Jul 29 06:05:16 PDT 2013

BLANDENIER Lucien wrote:

> Dear Grass users,
> I'm working with rasters maps of large area and I want to calculate surface
> related to specific colours. Before this, I have to replace the surfaces of
> the rivers by the surrounding value (or the mean of the surrounding value).
> I looked at the manual of r.mapcalc but I didn't found how to do this...
> For instance, I want to replace all value between 4 and 7 by the mean of the
> value of the 4 nearest pixels.
> Is there any way of doing this?
> Which command shall I use then for calculating the surface for each color?
> r.stats? or is there a command that directly computes the surface?

Dear Lucien,

did you get past this problem?

I think a combination of r.neighbours (to get the average values from 
surrounding cells) and r.recode (for re-categorising values in your input 
raster maps so as to get the desired output) + r.stats could do it.

Didn't try anything, of course -- not time.

Thanks, Nikos

More information about the grass-user mailing list