Hi,
I just added a new addon module, r.cog. It will calculate the center of
gravity of cells within a raster (not including NULLs) by coverage area.
Also it will take the mean elevation to combine with the center x,y to
create the 'pivot point' of the data.
https://trac.osgeo.org/grass/browser/grass-addons/grass6/raster/r.cog
The module will also allow you to calculate the average azimuth and dip
angle of the 2.5D raster surface, and optionally use that information,
together with the above pivot point, to create a new planar-trend raster
surface generalizing the DEM using the r.plane module.
Parsable 'shell script style' output is available, and for xmons in 6.x,
it will optionally draw a marker on the display.
There's a bug in the dip angle method though, in so far as I haven't figured
out the best way to calculate that yet.
My first attempt was to run r.univar on the derived slope map to look at
the {mean || median} slope and use that. But it is the wrong thing to do:
e.g. if you had some terrain riddled with canyons and pinnacles, but no
overall regional gradient, the mean slope would be quite high but the
overall region gradient would be near zero.
If all else fails we could use a 2D least-squares on the DEM, or perhaps
run v.surf.rst with very high smoothing and low tension ...?
I was trying to avoid that, as with the known* pivot point and generalized
azimuth we have only one unknown left to solve for in the calculation of
the plane... it seems like there is a simple solution in front of my nose
somewhere but I can't see it yet.
(* I'm guessing, but not 100% confident, that the mean elevation is a
suitable value to use for the pivot point's z-coord)
Perhaps the r.univar mean or median of the magnitude of the axes' 1st
derivatives:
r.mapcalc "tmp.magnitude = sqrt(tmp.rcog.$$.dx*tmp.rcog.$$.dx \
+ tmp.rcog.$$.dy*tmp.rcog.$$.dy)"
r.univar -g tmp.magnitude | grep mean
??
any ideas on how to do this?
Once this is working I suspect it will be a quite useful little module, for
analyses so far unthought of.
thanks,
Hamish