[GRASS-user] map calculator in python loop

Alessandro Sebastiani alessandro.sebastiani at uniroma1.it
Wed Dec 12 03:59:14 PST 2018


dear all,
i'm dealing this time with r.mapcalc. I have different rasters which i
grouped using g.list.
Now r_list contains all my raster. I want to multiply those rasters to
another raster (called "costante")  in order to obtain a new map, that i
want to call as r followed by the letter "k"
Here it is what i've done:
import grass.script as gscript
>>> r_list = gscript.read_command("g.list" , type = "rast"
).strip().split("\n")
>>> c = " costante"
>>> for r in r_list:
>>>     gscript.mapcalc ( " %s = %s * %s "  % ((r+"k") , r , c))

i get the following traceback message:

Invalid map <1>
parse error
ERROR: parse error
ERROR: An error occurred while running r.mapcalc
I don't really know where i'm wrong!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20181212/ff2fd5e2/attachment.html>


More information about the grass-user mailing list