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

Blumentrath, Stefan Stefan.Blumentrath at nina.no
Fri Apr 4 01:51:30 PDT 2014

Hi Rajat,

If you send me your two files I can send you a line of code that should work.
In this case I will need to know if you work with GRASS 6 or 7 and your operating system...


From: Rajat Nayak [mailto:rajat27404 at gmail.com]
Sent: 4. april 2014 04:47
To: Blumentrath, Stefan
Subject: Re: [GRASS-user] looping r.mapcalc in a shell script

Thank you Stefan for your reply.
One of the problems I'm facing with all the suggested codes is, the code is unable to find either of the file lists.
Both the filelists were created using g.mlist command, it it worked fine with other loops like reclass.
I will work again on your suggested line of thoughts, and hope will be able to crack it.

Rajat Nayak

On Thu, Apr 3, 2014 at 5:38 PM, Blumentrath, Stefan <Stefan.Blumentrath at nina.no<mailto:Stefan.Blumentrath at nina.no>> wrote:
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> [mailto: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<mailto: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<mailto:grass-user at lists.osgeo.org>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20140404/d188da7c/attachment.html>

More information about the grass-user mailing list