[GRASS-user] GRASS64 - r.mapcalc - replacement of specifics value by a mean of nearest neigbour
Moritz Lennert
mlennert at club.worldonline.be
Mon May 6 00:59:25 PDT 2013
On 04/05/13 20:17, 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?
Something like this:
newMap =if(oldMap >= 4 && oldMap <=7,
(oldMap[-1,0]+oldMap[0,-1]+oldMap[0,1]+oldMap[1,0])/4, oldMap)
>
> Which command shall I use then for calculating the surface for each color?
When you say color, I suppose you mean cell values.
> r.stats? or is there a command that directly computes the surface?
r.stats -a _does_ directly compute the surface.
Moritz
More information about the grass-user
mailing list