[GRASS-user] scripting mapcalc

Markus Neteler neteler at osgeo.org
Thu Mar 5 13:46:06 EST 2009

On Thu, Mar 5, 2009 at 3:42 PM, achim <ak7 at jupiter.uni-freiburg.de> wrote:
> Hi,
> did someone tried -like me- to use r.mapcalc in a script inside an
> do-while-clause?
> I cannot pass changing variables $old, $new like:
> r.mapcalc 'river=if(river=$old,$new,null())'
> its because of the '', which are needed because if the if-statement.

If you use single quotes '$foo', then the variables are protected.
You need to use double quotes: "$foo":
r.mapcalc "river=if(river=$old,$new,null())"


PS: In GRASS 7, you need white space (at least) before the equal sign:
       r.mapcalc "river = if(river=$old,$new,null())"
       (see its manual)

More information about the grass-user mailing list