[GRASS-user] Re: r.mapcalc and nested if

thedok78 thedoktor78 at gmail.com
Fri Apr 16 09:35:47 EDT 2010


Thank you all for yours answers!
I'll explain my problem:

I have got a raster map with a lot of small area like this one:

112 112 112 122 112
112 112   1     1   122
122   1     1     1   122
112 122 122 112 112

The boundary is made cells with values from 100 to 200 instead the inner
ones have got 1 as value.
I need to fill the inner cells with the mode of a 3x3 window.
Using a loop until there are no more cell with 1 as value, I started with
this approach:

map=if(map ==
1,mode(map[-1,-1],map[-1,0],map[-1,1],map[0,1],map[1,1],map[1,0],map[1,-1],map[0,-1]),0)

I added the map == 1 condition due the null cells outside the boundary,
which set the mode to null and slowly eat all my areas :)

Using that syntax the loop goes smooth but after a certain point the cells=1
remain the same because the mode is always 1.

I discarded r.neighbors because it changes also the values on the boundary
which should remain the same.

Any hint?
Thank you very much.

Luca

-- 
View this message in context: http://n2.nabble.com/r-mapcalc-and-nested-if-tp4901916p4913028.html
Sent from the Grass - Users mailing list archive at Nabble.com.


More information about the grass-user mailing list