On Wed, Mar 02, 2005 at 10:06:47AM +0000, Paul Kelly wrote:
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
Dou you mean something like
rg = \
if(!isnull(seed[-1,-1]) && (raster[-1,-1]> raster[1,1]),1,\
if(!isnull(seed[-1,0] ) && (raster[-1,0] > raster[1,0]),1,\
if(!isnull(seed[-1,1] ) && (raster[-1,1] > raster[1,-1]),1,\
if(!isnull(seed[0,-1] ) && (raster[0,-1] > raster[0,1]),1,\
if(!isnull(seed[0,1] ) && (raster[0,1] > raster[0,-1]),1,\
if(!isnull(seed[1,-1] ) && (raster[1,-1] > raster[-1,1]),1,\
if(!isnull(seed[1,0] ) && (raster[1,0] > raster[-1,0]),1,\
if(!isnull(seed[1,1] ) && (raster[1,1] > raster[-1,-1]),1,null()))))))))
??
But I need to detect neighbourhood of the central point, if it is
"notnull()"...
OOh, I have it:
if(x) = TRUE if x != 0, but
if(x) = TRUE if isnull(x)
(I hope, you can understand).
Now I run
rg = \
if(seed, 1, \
if(seed[-1,-1] && (raster[-1,-1]> raster[1,1]),1,\
if(seed[-1,0] && (raster[-1,0] > raster[1,0]),1,\
if(seed[-1,1] && (raster[-1,1] > raster[1,-1]),1,\
if(seed[0,-1] && (raster[0,-1] > raster[0,1]),1,\
if(seed[0,1] && (raster[0,1] > raster[0,-1]),1,\
if(seed[1,-1] && (raster[1,-1] > raster[-1,1]),1,\
if(seed[1,0] && (raster[1,0] > raster[-1,0]),1,\
if(seed[1,1] && (raster[1,1] > raster[-1,-1]),1,\
0)))))))))
where seed is map containing 1 and 0 but NOT null values. Now it works fine.
it is in xif.c file:
/********************************************************************
if(a) 1,0,1 1 if a is non zero, 0 otherwise
if(a,b) b,0,b b if a is non zero, 0 otherwise
if(a,b,c) b,c,b b if a is non zero, c otherwise
if(a,b,c,d) d,c,b b if a is positive, c if a is zero, d if a is negative
********************************************************************/
should be
/********************************************************************
if(a) 1,0|null,1 1 if a is non zero AND not null, null otherwise
...
But I don't know, how to corect it...
Jachym
--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://www.fle.czu.cz/~jachym/gnupg_public_key/