Changes in the r.mapcalc syntax in GRASS GIS 7

After some frustrating failed attempts to do some simple raster calculations in GRASS (version 7.0), I found out there is a small change in the syntax for r.mapcalc in GRASS GIS 7:

The old syntax would look something like:

r.mapcalc 'newmap=oldmap*2'

In GRASS GIS 7 you need to add spaces around the equal sign:

r.mapcalc "newmap = oldmap*2"

The good thing is that the new syntax is backwards compatible, you can use it in GRASS 6.x too.

There is however one other important change. In the old syntax, r.mapcalc would overwrite existing maps without warning. In the new syntax, you need to explicitly indicate that existing maps should be overwritten, using the –overwrite flag.

There is also the option to specify a file containing r.mapcalc expressions, check the manual for more details

In summary:

r.mapcalc "outmap = inmap"       # works with both 6.x and 7.0
r.mapcalc expr="outmap = inmap"  # won't work with 6.x
r.mapcalc "outmap=inmap"         # won't work with 7.0
r.mapcalc outmap = inmap         # won't work with 7.0

I found the answer here, and of course I should have gone directly to the man page of r.mapcalc of GRASS 7.0.


One thought on “Changes in the r.mapcalc syntax in GRASS GIS 7

  1. Pingback: New features and renamed options in GRASS 7 | Ecostudies

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s