[GRASS-user] looping r.mapcalc in a shell script

Blumentrath, Stefan Stefan.Blumentrath at nina.no
Thu Apr 3 05:08:48 PDT 2014

You could also combine your two lists using the "paste" command, then "awk" in order to create proper map calculator expressions, which you then can send to the map calculator through "xargs".
That way you could process the maps in parallel (if you are on a 64bit system with multi cores)...

Something like (would likely require some adjustments, e.g. regarding field delimiters):
paste NDVIFILES VIQALIST | awk '{print \" $1 "_MASK"=$1 '" * " $2 \"}' | xargs -P 4 r.mapcalc {}


-----Original Message-----
From: grass-user-bounces at lists.osgeo.org [mailto:grass-user-bounces at lists.osgeo.org] On Behalf Of rajatrn
Sent: 3. april 2014 10:31
To: grass-user at lists.osgeo.org
Subject: [GRASS-user] looping r.mapcalc in a shell script

I have two layer lists, NDVIFILES and VIQALIST, both developed using g.mlist command in GRASS.
Each file has 22 items in it. I would like to perform a simple raster calculation of the following form, Mask$NDVIFILES [i] = NDVIFILES[i] * VIQALIST[i] I'm unable to create a loop which can sequentially produce the required outputs.
I will be grateful if anyone can help me with creating a loop using bash/shell script.
I know it is simpler to do it in R but will be great if can be implemented on using grass terminal/shell.
Thank you in advance,

View this message in context: http://osgeo-org.1560.x6.nabble.com/looping-r-mapcalc-in-a-shell-script-tp5132797.html
Sent from the Grass - Users mailing list archive at Nabble.com.
grass-user mailing list
grass-user at lists.osgeo.org

More information about the grass-user mailing list