[GRASSLIST:1393] Re: r.mapcalc

Markus Neteler neteler at geog.uni-hannover.de
Tue Jan 23 12:21:21 EST 2001


On Tue, Jan 23, 2001 at 12:32:30PM -0300, Horacio wrote:
> Hi, 
> I'm trying to embed r.mapcalc command in a bash script... I'm having
> troubles understanding how r.mapcalc handles variables...
> 
> for example in a for loop:
> 
> r.mapcalc final_$sp_name = $sp_name && (dem <= $((max_$sp_name)) && (dem
> >= $((min_$sp_name))
> 
> 
> I understand that some characters can cause troubles in the shell
> interpretation for wich I should use something like...
> 
> 
> r.mapcalc final_$sp_name \= $sp_name \&\& \(dem \<\= $((max_$sp_name))
> \&\& \(dem \>\= $((min_$sp_name))\)
> 
> 
> but it still doesn't work... 

Horacio,

 it's pretty easy:

 r.mapcalc final_$sp_name="formula"
                          ^       ^

This will prevent the shell from expaning braces etc. wrongly.
However, you will need to use the "if()" function if you want to
test values.

See:
 http://www.geog.uni-hannover.de/grass/gdp/html_grass5/html/r.mapcalc.html
 
 and the two refs mentioned in "SEE ALSO" on this page.

Hope this helps

 Markus 




More information about the grass-user mailing list