[GRASSLIST:4028] Re: GRASS4.3 mapcalc
Soil & Water Lab.
swlab at cornell.edu
Thu Jul 4 16:52:14 EDT 2002
Hi,
This topic is referenced in the help manual, r.mapcalc entry...
"Extra care must be taken if the expression is given on the command line. Some
characters have special meaning to the UNIX shell. These include, among
others:
* ( ) > & |
It is advisable to put single quotes around the expression; e.g.:
result = 'elevation * 2'
Without the quotes, the *, which has special meaning to the UNIX shell, would
be altered and r.mapcalc would see something other than the *. "
That's the main trick : it seems that you forgot the single quote.
Basically, always use quotes.
A nice trick with scripts : if you want to refer to maps by using variable
names, you may prefer the syntax
echo "your formula" | r.mapcalc
echo "newmap=$oldmapname*2." | r.mapcalc
example
fieldmap= fields2
randrast=randrast2
echo "randfood=$fieldmap*$randrast" | r.mapcalc
--
------------------------------
Soil and Water Laboratory
Biological and Environmental Engineering Department
Cornell University
Riley-Robb Hall
ITHACA, NY 14853 - USA
More information about the grass-user
mailing list