[GRASS-dev] r.neighbors modification
Glynn Clements
glynn at gclements.plus.com
Thu Nov 23 23:12:52 EST 2006
Hamish wrote:
> > > > r.mfilter ?
> > >
> > > that looks good, but as far as I understood it, it is not possible
> > > to conduct statistics on this filter (beside divisor), is it?
> >
> > I don't think that you can compute anything except for sum and mean
> > using r.mfilter.
By "anything", I mean that these are the only "standard" aggregates
(those offered by r.neighbors) which can be computed.
> is this an inherent limitation of the method, or has it just not been
> coded yet?
The former. The result is just a weighted sum of the cells in the
window, so you are limited to linear functions.
An all-ones matrix with a divisor of one gives the sum, while an
all-ones matrix with a divisor equal to the number of ones gives the
mean.
All of the other standard aggregates have some kind of non-linearity.
Variance and standard deviation can be implemented using two passes of
each of r.mfilter and r.mapcalc, e.g.:
r.mfilter input=foo output=foo.sum filter=sum.txt
r.mapcalc "foo.sq = foo^2"
r.mfilter input=foo.sq output=foo.sumsq filter=sum.txt
r.mapcalc "foo.var = (foo.sumsq - foo.sum^2/$N)/$N ; foo.sdev = sqrt(foo.var)"
> it would be nice to have a powerful r.mfilter (not as grand as
> r.mapcalc, but more customizable than just sum+mean.
There isn't really any "obvious" intermediate level between the linear
filters which are already available in r.mfilter and the arbitrary
expressions offered by r.mapcalc.
E.g. I can't think of any enhancement which would allow you to
implement median/minimum/maximum filters.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list