[GRASS-user] summation

goldneaa at onid.orst.edu goldneaa at onid.orst.edu
Thu Jul 12 15:51:55 EDT 2007


the script for adding 120 rasters worked.
set i=1
set str="r.mapcalc map=ts.1"

while($i <= 120)
set str="$str + map.$i"
@ i++
end

There is a limit to the command line around 383 rasters, so if I want  
to add more rasters together than this I need to use a loop command.   
What I have so far is

set sum=0
set i=1
set str="r.mapcalc sum=temp.1"
foreach raster ( `g.mlist rast pattern="temp.*" )

Basically what I need is to have a script that will take create a  
running sum to add to the next raster file.  Like (temp.1 +  
temp.2)=Sum.temp.  This first sum needs to be added to temp.3.  Then  
the loop needs to take action so I can continue to culminate the sums  
to be added to the next map layer.
Thanks for reaading,
Aaron




More information about the grass-user mailing list