[GRASS5] region growing - r.mapcalc bug?

Hallo,
I try to produce some region growing map after the approach descriped in
"r.mapcalc: An Algebra for GIS and Image Processing" (site no. 7) from
http://grass.itc.it/gdp/raster/mapcalc-algebra.pdf (to be found also on
http://grass.itc.it/grass60/manuals/html60_user/r.mapcalc.html).

I try something like this:

rg = if(bod,bod, \
         if (bod[0,-1], 1, \
             if(bod[0,1], 1, \
                 if(bod[-1,0], 1, \
                     if(bod[1,0],1)))))

The only result I get, is the "central" point (bod[0,0]), no neighborhood is
produced :-/

Could it be some bug in r.mapcalc code?

Thank you

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

hallo,
On Wed, Mar 02, 2005 at 11:25:02AM +1300, Hamish wrote:

> I try to produce some region growing map after the approach descriped in
> "r.mapcalc: An Algebra for GIS and Image Processing" (site no. 7) from

did you try r.grow? (new module for GRASS 6 versus old GRASS 5 version)

The problem is, I need something more complicated:
     if(seed && (raster[-1,-1]> raster[1,1]),sead+1,\
     if(seed && (raster[-1,0] > raster[1,0]),sead+1,\
     if(seed && (raster[-1,1] > raster[1,-1]),sead+1,\
     if(seed && (raster[0,-1] > raster[0,1]),sead+1,\
     if(seed && (raster[0,1] > raster[0,-1]),sead+1,\
     if(seed && (raster[1,-1] > raster[-1,1]),sead+1,\
     if(seed && (raster[1,0] > raster[-1,0]),sead+1,\
     if(seed && (raster[1,1] > raster[-1,-1]),sead+1,null()))))))))

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

On Wed, Mar 02, 2005 at 08:08:45AM +0100, Jachym Cepicky wrote:

     if(seed && (raster[-1,-1]> raster[1,1]),sead+1,\
     if(seed && (raster[-1,0] > raster[1,0]),sead+1,\
     if(seed && (raster[-1,1] > raster[1,-1]),sead+1,\
     if(seed && (raster[0,-1] > raster[0,1]),sead+1,\
     if(seed && (raster[0,1] > raster[0,-1]),sead+1,\
     if(seed && (raster[1,-1] > raster[-1,1]),sead+1,\
     if(seed && (raster[1,0] > raster[-1,0]),sead+1,\
     if(seed && (raster[1,1] > raster[-1,-1]),sead+1,null()))))))))

sorry, I need
if(seed[-1,-1] && (raster[-1,-1]> raster[1,1]),seed[-1,-1]+1,\
     if(seed[-1,0] && (raster[-1,0] > raster[1,0]),seed[-1,-1]+1,\
     if(seed[-1,1] && (raster[-1,1] > raster[1,-1]),seed[-1,1]+1,\
     if(seed[0,-1] && (raster[0,-1] > raster[0,1]),seed[0,-1]+1,\
     if(seed[0,1] && (raster[0,1] > raster[0,-1]),seed[0,1]+1,\
     if(seed[1,-1] && (raster[1,-1] > raster[-1,1]),seed[1,-1]+1,\
     if(seed[1,0] && (raster[1,0] > raster[-1,0]),seed[1,0]+1,\
     if(seed[1,1] && (raster[1,1] > raster[-1,-1]),seed[1,1]+1,null()))))))))

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

On Wed, 2 Mar 2005, Jachym Cepicky wrote:

sorry, I need
if(seed[-1,-1] && (raster[-1,-1]> raster[1,1]),seed[-1,-1]+1,\
    if(seed[-1,0] && (raster[-1,0] > raster[1,0]),seed[-1,-1]+1,\
    if(seed[-1,1] && (raster[-1,1] > raster[1,-1]),seed[-1,1]+1,\
    if(seed[0,-1] && (raster[0,-1] > raster[0,1]),seed[0,-1]+1,\
    if(seed[0,1] && (raster[0,1] > raster[0,-1]),seed[0,1]+1,\
    if(seed[1,-1] && (raster[1,-1] > raster[-1,1]),seed[1,-1]+1,\
    if(seed[1,0] && (raster[1,0] > raster[-1,0]),seed[1,0]+1,\
    if(seed[1,1] && (raster[1,1] > raster[-1,-1]),seed[1,1]+1,null()))))))))

Have you tried the isnull() function in r.mapcalc? That old tutorial you linked to was written for GRASS 4 where there was no null cell concept.

Paul