[GRASSLIST:281] Re: r.mapcalc puzzler
Glynn Clements
glynn.clements at virgin.net
Tue Jun 3 07:58:55 EDT 2003
H Bowman wrote:
> I'm using a modification of the script given here:
> http://op.gfz-potsdam.de/GRASS-List/Archive/msg07811.html
>
> which includes the following mapcalc magic to do a better r.grow:
>
> r.mapcalc << EOF
> grown = if( $src, $src, \\
> if($src[0,-1], $src[0,-1], \\
> if( $src[0,1], $src[0,1], \\
> if($src[-1,0], $src[-1,0], \\
> if( $src[1,0], $src[1,0] \\
> )))))
> EOF
>
> Now this was working fine.. but after playing with the script it would
> break on the mapcalc line with:
>
> undefined function:
> Syntax error
>
> Ok so looking through it, I can't make sense why it is failing. Adding a
> ",0" to the last "if" fixes it, but that shouldn't be necessary:
>
> if(x,a) a if x not zero, 0 otherwise
> if(x,a,b) a if x not zero, b otherwise
>
> I tried removing all whitespace too, no luck.
>
> I've got it working now with the extra, just can't figure out why
> it broke, which bugs me. This is the r.mapcalc3 from 5.0.2, bash, and
> linux.
>
> previously, I'd gotten this error:
> Illegal filename. character <> not allowed.ERROR: open_map: map [] not found
> when I had src=grown.tmp$$. That went away sometime after I made
> it just grown.tmp though.
>
> Can't see what I'm missing.
I can't reproduce the problem here.
Could some kind of non-printing character have crept into the script?
--
Glynn Clements <glynn.clements at virgin.net>
More information about the grass-user
mailing list