[GRASS-user] Looking for a Grass equivalent to ESRI'sFocalmean(grid, ANNULUS, irad, orad)

Glynn Clements glynn at gclements.plus.com
Sat Sep 1 13:21:54 EDT 2007


Moskovitz, Bob wrote:

> I was just looking at the CVS version of r.neighbors but didn't see
> where I can specify use an arbitrary neighbourhood shape unless it has
> something to do with the weight=string option. Unfortunately the
> documentation doesn't mention how to use it.

The argument to the weight= option is the name of a file containing
weights. The file should contain NxN floating-point values (anything
acceptable to scanf's %f conversion).

> So, with r.neighbors, how would I annulus shape neighbourhood shape?

Create a weights file with a non-zero value for each cell which should
be part of the neighbourhood, and zero elsewhere. E.g. for size=5:

 0 1 1 1 0
 1 0 0 0 1
 1 0 0 0 1
 1 0 0 0 1
 0 1 1 1 0

The minimum, maximum, diversity and interspersion aggregates don't
care about the actual weight; they simply discard any values with a
zero weight and retain those with a non-zero weight.

For the other aggregates, the way in which the weights affect the
aggregate is fairly intuitive. In particular, an integer weight has
the same effect as repeating the value that may times (integer weights
aren't treated specially; this is just a consequence of how the
weights are handled).

Finally, note that r.neighbors, r.series and r.resamp.stats all use
use the same code for the aggregates (although r.series only uses the
unweighted forms).

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-user mailing list