[GRASS-user] summation

Hamish hamish_nospam at yahoo.com
Sun Jul 15 19:27:59 EDT 2007


goldneaa wrote:
> 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.  

You are probably hitting a maximum command line length of 4096 chars,
not a max open map/file limit. (?)


> 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.


another idea is to add 1-100 together into sum1, 101-200 into sum2,
201-300 into sum3 etc, then finish with
  r.series method=sum in=sum1,sum2,sum3 out=sum_total


Hamish




More information about the grass-user mailing list