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

>Message: 5
>Date: Sun, 14 Feb 2010 03:38:19 -0800 (PST)
>From: Gazz1982 <garynobles@yahoo.com>
>Subject: [GRASS-user] calculating maximum and minimum diameters with
> GRASS or R and GRASS?
>To: grass-user@lists.osgeo.org
>Message-ID: <1266147499876-4569832.post@n2.nabble.com>
>Content-Type: text/plain; charset=us-ascii
>
>Hi,
>
>I have 900 polygons and I need to calculate their maximum and minimum
>diameters I have GRASS and R and MySQL on Ubuntu, although my R skills are
>still developing. I really do not want to measure each one by hand as I do
>not have the time! I have managed easily to calculate perimeter and area,
>anyone know how to do this?
>
>thanks
>
>Gary

Gary,

Use v.to.db, option=perimeter. This will upload the polygons' perimeters to a database table (you will need a perimeter column in the database, of course). From there, you can select the max and min with no trouble.

Hence:
v.db.addcol <map> columns="Perimeter double"
v.to.db <map> option=perimeter units=me column=Perimeter
v.db.select <map>

Richard

Ok sorry I will reword the question.

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?
--
View this message in context: http://n2.nabble.com/Re-calculating-maximum-and-minimum-diameters-with-GRASS-or-R-and-GRASS-tp4577146p4609066.html
Sent from the Grass - Users mailing list archive at Nabble.com.

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