[GRASS-user] Averaging a set of rasters

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?
Thanks,
Seth

I think “r.series method=average …” should do the trick.

On Wed, Sep 7, 2011 at 12:27 AM, Seth Price <seth@pricepages.org> 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?
Thanks,
Seth_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

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

Hamish

ps- did that missing header file for the OpenCL version ever make
it into github?

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@gclements.plus.com>