[GRASSLIST:6383] Re: r.mapcalc growing area

Jachym Cepicky jachym.cepicky at centrum.cz
Sat Apr 9 12:57:08 EDT 2005


On Sat, Apr 09, 2005 at 07:33:19PM +0300, M?ris Nartišs wrote:
> Hi all,
> today I realised that Im too dubm to use r.mapcalc :) r.mapcalc is too
> powerfull tool for my small brain.
> I have two raster maps map1 and map2. map1 covers whole teritory, but
> map2 contains only one cell. I want to modify map2  in following way:
> if map2 cell not null -> calculate new value from map1 and also
> calculate (and assign) new values to all 8 neighborhood cells (i.e.
> [1,1], [-1,0] etc.)
> I cant find way how to assign new values to all neighborhood cells and
> do it only if they are one cell far from map2 cell with value. As
> calculating new values takes aditional checks, I always fail in logic.
> :(
> Some aditional qs:
> 1) can ! be used to reverse things (ie. !isnull(x) to chek if x is not null)?
> 2) is any way to get some feedback from r.mapcalc was any cell
> affected by last command/action? It s need to know if there is need to
> do additional calculating pass ower data.
> tnx for any ideas,
> Maris.

I made with r.mapcalc the experience, that it is general better to work on map
with 0 instad of NULL value :-/ 

I wrote some script, which tryes to provide region growing  on the base map
(something like digital elevation model)...

maybe it will help you to understand, how the things should be done:

output = \\
     if(seed, 1, \\
     if(seed[-1,-1] &&  (input[-1,-1]> input[1,1]),1,\\
     if(seed[-1,0]  &&  (input[-1,0] > input[1,0]),1,\\
     if(seed[-1,1]  &&  (input[-1,1] > input[1,-1]),1,\\
     if(seed[0,-1]  &&  (input[0,-1] > input[0,1]),1,\\
     if(seed[0,1]   &&  (input[0,1]  > input[0,-1]),1,\\
     if(seed[1,-1]  &&  (input[1,-1] > input[-1,1]),1,\\
     if(seed[1,0]   &&  (input[1,0]  > input[-1,0]),1,\\
     if(seed[1,1]   &&  (input[1,1]  > input[-1,-1]),1,\\

good luck with NULL value, I did not have it..


Jachym Cepicky
e-mail: jachym.cepicky at centrum.cz
URL: http://les-ejk.cz
GPG: http://www.fle.czu.cz/~jachym/gnupg_public_key/

More information about the grass-user mailing list