[GRASS-user] looping r.mapcalc: problem with MASK
Stefan Sylla
fabiosela at gmx.de
Fri Apr 22 23:36:29 EDT 2011
Dear list,
I have some RGB Satellite images that I need to perform a r.mapcalc function
on within a MASK.
Can anyone explain me, why with
for i in `g.mlist -e type=rast
pat="[ta]_(e_p2\.[rgb])|(a_p1\.[rgb])|(e_7170_p5\.[rgb])"`
do
g.region "rast=$i" "res=0.001"
mask=$(basename ${i/.*/.mask})
g.copy "rast=$mask,MASK" "--o"
r.mapcalc "$(basename ${i/./cc.})=#$i"
done
the MASK is not applied on during r.mapcalc? (The mask is applied when I run
"r.mapcalc newfile=#oldfile" on its own, without any looping)
I can use the loop if I add a second r.mapcalc run on it (s. last line):
for i in `g.mlist -e type=rast
pat="[ta]_(e_p2\.[rgb])|(a_p1\.[rgb])|(e_7170_p5\.[rgb])"`
do
g.region "rast=$i" "res=0.001"
g.copy "rast=$(basename ${i/.*/.mask}),MASK" "--o"
newfile=$(basename ${i/./cc.})
r.mapcalc "$newfile=#$i"
r.mapcalc "$newfile=$newfile"
done
But I don't like this solution, because I have to run r.mapcalc twice which
costs a lot of time! Anyone has an idea on how to avoid running r.mapcalc
twice in this loop?
All the best
Stefan
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/looping-r-mapcalc-problem-with-MASK-tp6298797p6298797.html
Sent from the Grass - Users mailing list archive at Nabble.com.
More information about the grass-user
mailing list