[GRASSLIST:282] RE: r.mapcalc puzzler
Matt Doggett
mdoggett at coas.oregonstate.edu
Tue Jun 3 11:36:51 EDT 2003
Don't you need quotes around a complicated expression like that? I've
always used %> r.mapcalc "a=sin(b)+cos(c)" so that the special
characters don't throw the shell into a tizzy.
md
-----Original Message-----
From: owner-GRASSLIST at baylor.edu [mailto:owner-GRASSLIST at baylor.edu] On
Behalf Of H Bowman
Sent: Tuesday, June 03, 2003 4:21 AM
To: grass list
Subject: [GRASSLIST:279] r.mapcalc puzzler
Hi -
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.
?
thanks,
Hamish
More information about the grass-user
mailing list