[GRASS-user] How to initialize raster maps.
Marcello Gorini
gorini at gmail.com
Sat Dec 10 12:05:40 EST 2011
Moritz:
>As Glynn suggests:
>
>
> for i = 1 to 10
> sum_new = sum + i
> g.remove rast=sum
> g.rename rast=sum_new,sum
>
>
>
OK, sorry, I got so scared I overlooked Glynn's suggestion. I did another
experiment to see the differences in processing time. Since I iterate 1260
times in my script, I tried the following alternatives with "i" varying
from 1 to 1260:
1 - r.mapcalc "sum=sum+$i" # my suspicious way
2 - r.mapcalc "sum_new = sum + $i" # Glynn's suggestion after
Moritz's explanation
g.remove rast=sum --q
g.rename rast=sum_new,sum --q
3 - r.mapcalc "sum_new = sum + $i" # Moritz's suggestion
g.rename rast=sum_new,sum --overwrite --q
Results:
1 - 125 seconds
2 - 183 seconds
3 - 154 seconds
Bottom line:
If Glynn says Moritz suggestion with the g.rename --overwrite is OK, I will
give back the 30 seconds Moritz had saved me before :) and end up with 30
seconds more of processing time, but with no undefined behaviour.
If method number 2 must be used, I will end up with 60 seconds more, what
won't do me any harm anyway.
Thanks a lot for this interesting exercise.
Cheers,
Marcello.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20111210/731a3138/attachment.html
More information about the grass-user
mailing list