[GRASSLIST:4650] Re: sum in r.mapcalc

Glynn Clements glynn.clements at virgin.net
Fri Oct 4 09:15:24 EDT 2002


Otto Dassau wrote:

> > > I want to calculate the average and standard deviation of a image time
> > > series. To calculate the average in r.mapcalc is no problem, but how
> > > can I calculate s.d.? I couldn't find a sum sign in the manual. Or is
> > > there already a command for calcualting s.d. of several images?
> > 
> > r.mapcalc doesn't include variance or standard deviation functions. It
> > doesn't have a variadic "sum" operator either; you would need to write
> > it as e.g. "a + b + c".
> 
> r.univar is a shell script calculating standard deviation from 
> r.stats output. Maybe there you find a solution.

r.univar provides overall statistics for a single map.

Given the references to "time series" and r.mapcalc, I assumed that
Martin was interested in computing a mean and standard deviation for
each cell, from the corresponding cells of each raster in the series.

Assuming that this is the case, currently he would need to write out
the computation for standard deviation explicitly using the basic
arithmetic operators.

However, it isn't particularly hard to add new functions to r.mapcalc. 
I'm open to suggestions from the list as to which functions should be
added to future versions of r.mapcalc.

The question also suggests that there might be some use for a tool
which is specifically targeted at time series. Something similar to
r.neighbors[1], but which computes aggregates of the corresponding
cells of a sequence of maps rather than of the surrounding cells in a
single map.

[1] r.neighbors computes the aggregates: mean, median, mode, minimum,
maximum, stddev, sum, variance, diversity and interspersion. Again,
the list could be extended without much difficulty.

-- 
Glynn Clements <glynn.clements at virgin.net>



More information about the grass-user mailing list