[GRASS-user] Averaging a set of rasters
Glynn Clements
glynn at gclements.plus.com
Thu Sep 8 03:53:37 EDT 2011
Hamish wrote:
> > Is there any way to take a set of rasters (the output from many
> > days of r.sun, for example) and average all their values
> > together?
>
> sure, use r.series. Rather than doing the average directly (which
> you can do), a common way is to create a sum map and then manually
> use r.mapcalc to divide by the number of days to get the avg. I
> guess running r.series twice would be just as good..
Note that by default, r.series calculates the aggregate over the
non-null values, so the average of [1,null,2] is (1+2)/2 = 1.5, not
(1+2)/3 = 1.
Dividing the result of "r.series method=sum" by a fixed denominator
will result in nulls effectively being treated as zeros (i.e. they
don't affect the sum but they're accounted for by the denominator).
If you want to separate the steps, divide the result of
"r.series method=sum" with the result of "r.series method=count"; the
latter counts the number of non-null input cells.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user
mailing list