[GRASS-dev] formatting expressions for r.mapcalc in GRASS6.4.3

Markus Neteler neteler at osgeo.org
Fri Feb 1 11:58:46 PST 2013


On Fri, Feb 1, 2013 at 4:16 AM, Helena Mitasova <hmitaso at ncsu.edu> wrote:
> Over the years there have been changes in the formatting of r.mapcalc expressions
> and it appears the currently there is no single way that would work everywhere

I use it for a long time and have a standard formatting which always works...


...
> GRASS 6.4.3RC2 (nc_spm_08):~ > r.mapcalc result = 'elevation * 2'

I use and recommend:

r.mapcalc "result = elevation * 2"

Note:
- space before and after = like this it is GRASS 7 compliant
- " expression ...": avoiding the single ' you can use shell variable
expansion like

  VAR1=2.0
  r.mapcalc "result = elevation * $VAR1"

Like this you are fine with GRASS7, too.

Markus


More information about the grass-dev mailing list