[GRASS-user] Re: calculating maximum and minimum diameters with, GRASS or R and GRASS?

Hamish hamish_b at yahoo.com
Mon Feb 22 01:06:16 EST 2010


Gary Nobles wrote:
> I have 900 polygons I wan to calculate a max and min
> diameter for each individual polygon
> 
> so poly1 max diamter=n min diamter=n
> 
> I have already got a diameter and area from the db. modules, however I can
> only get an idealised diamter using pie r ^2 so not what I want
> 
> Thanks for any suggestions, can R do this?


so what you want to do is fit an ellipsoid to the polygon, and then
examine the radii of the major and minor axes.

code to find the center-of-mass of the polygon is surely out there
somewhere, that gets the 0,0 point of the ellipsoid. from there you'd
need something that did e.g. a least-squares fit to an ellipsoid.

maybe after translating the COM to 0,0 throw the polygon at some sort
of PCA*-like function in R. maybe you need to convert the filled polygon
area to high-density random dots (or regularly spaced grid of dots) to
get that to work right.

[*] http://en.wikipedia.org/wiki/Principal_component_analysis

Once you know the angle of the primary axis take an average of the
distance to polygon along that angle at at an angle of 180. For the
minor axis radius take an average of the +90 and +270 relative to the
major axis alignment.

maybe I'm making it more complicated than it has to be, but I think it
would work.


Hamish



      


More information about the grass-user mailing list