[GRASS-user] How to sum a hundred of raster maps using r.mapcalc

Vaclav Petras wenzeslaus at gmail.com
Thu Sep 8 10:38:28 PDT 2016


On Thu, Sep 8, 2016 at 1:27 PM, Robert Kuszinger <kuszinger at giscom.hu>
wrote:

> Do you use Linux or something similar? I can't test but maybe works on
> Windows as well with bash shell:
>
>
> r.mapcalc expression=resultmap=`g.list type=raster pattern=arc_0*
> separator='+'`
>


Even on Linux, this can fail when the expression is too long (operating
system limits the length of a command), but that's what the file parameter
is for in r.mapcalc. You can save the g.list result to a file, in Bash:

g.list type=raster pattern="elev*" separator='+' >> expression.txt

add whatever else is needed in the expression and then use the file
parameter in r.mapcalc (same idea as what Veronica suggests for r.series):

r.mapcalc file=expression.txt

For simple cases, r.series is just simpler as Veronica suggests.

Vaclav

https://grass.osgeo.org/grass70/manuals/r.mapcalc.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20160908/fa956022/attachment.html>


More information about the grass-user mailing list