[GRASSLIST:6233] Re: r.neighbor inside r.mapcalc
Glynn Clements
glynn.clements at virgin.net
Fri May 9 06:27:18 EDT 2003
Daniel Victoria wrote:
> I'm trying to run r.neighbor on selected cells. What I
> want to do is to substitute specific cell values
> (lower than 10 for instance) with the value produce by
> a r.neighbor average. Is there a way to do this in
> GRASS?
If I understand you correctly, the simplest way to do this is to first
create a new map with r.neighbors, then use r.mapcalc to choose
between the original map and the new map, e.g.
r.neighbors input=origmap output=newmap method=average size=7
r.mapcalc 'result = if(origmap < 10, newmap, origmap)'
> I tried r.mapcalc but I got a little confused with the
> neighbor operand [r,c]. For a 3x3 window the [r,c] in
> r.mapcalc should be easy but for something larger
> (7x7) it would be a lot more work. Is there an easyer
> way?
Re-implementing r.neighbors in r.mapcalc is impractical for large
window sizes; there aren't any looping constructs, so there isn't any
way of doing it without writing N-squared distinct terms (e.g. 49
terms for a 7x7 window).
--
Glynn Clements <glynn.clements at virgin.net>
More information about the grass-user
mailing list