[GRASS-user] using mapcalc in a python script
Glynn Clements
glynn at gclements.plus.com
Thu Jul 1 07:39:07 EDT 2010
Ned Horning wrote:
> I am working on converting a shell script to python and ran into a
> problem I haven't been able to figure out using the r.mapcalc command.
> Can someone let me know how to write the following command using python.
> The command creates a GRASS MASK layer:
>
> r.mapcalc "MASK=if(($cloudResampName < 0.01000),1,null())"
import grass.script as grass
...
grass.mapcalc("MASK=if(($cloudResampName < 0.01000),1,null())",
cloudResampName = cloudResampName)
The first argument to the mapcalc function is a template (see the
Python library documentation for string.Template). Any keyword
arguments (other than quiet, verbose or overwrite) specify
substitutions.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user
mailing list