[GRASS-user] GRASS Scripting questions
Glynn Clements
glynn at gclements.plus.com
Thu Dec 17 16:50:49 EST 2009
António Rocha wrote:
> Greetings Achim
> You are absolutely right. I made a mistake copying the expression.
>
> Here it goes:
> #itinialization of counter1
> r.mapcalc $GIS_OPT_COUNTER1= "float (0)"
>
> The cycle:
> IFS=,
> for opt in $GIS_OPT_INPUT; do
> r.mapcalc $GIS_OPT_COUNTER= "$opt+$GIS_OPT_COUNTER"
> done
Don't use the same map as both input and output. Instead:
tmp=tmp.myscript.$$
for opt in $GIS_OPT_INPUT; do
r.mapcalc "$tmp = $opt + $GIS_OPT_COUNTER"
g.rename --o rast=$tmp,$GIS_OPT_COUNTER
done
Although for this specific task (adding a list of maps), use
"r.series ... method=sum".
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user
mailing list