[GRASS-dev] GRASS r.neighbors
Glynn Clements
glynn at gclements.plus.com
Mon Jul 21 14:38:05 EDT 2008
chris carleton wrote:
> I've encountered another challenge with GRASS that I need some expert
> advice with. I want to run a neighborhood analysis on a few DEMs,
> but the options in r.neighbors don't quite seem to suit my needs. I
> want an analysis that calculates the average difference between the
> central cell and its neighbors (using that average as the new cell cat
> value). The idea is that I'll end up with an approximation of terrain
> 'ruggedness' by looking at average differences in elevation within a
> given neighborhood. Any suggestions would be welcome.
By "average" are you referring to the mean difference, or the mean
absolute difference?
If it's the mean difference:
sum(x[i] - x[centre]) / count
= sum(x[i]) / count - x[centre]
so you can use "r.neighbors method=average" then subtract the original
map from the result with r.mapcalc.
OTOH, if it's the absolute difference (or anything else where you
can't rearrange it so that the operation falls outside of the
summation), you'll need to extend r.neighbors (you could use
r.mapcalc, but that's both slow and ugly if you have a large
neighborhood).
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list