[GRASS-user] Computing major and minor axes for polygons

Nikos Alexandris nik at nikosalexandris.net
Tue Nov 25 09:10:38 PST 2014


On 24.11.2014 23:50, Benjamin Ducke wrote:
> Right, a PCA of the polygon vertices, I assume?
> Maybe "v.to.db" could be enhanced to allow it to upload
> the lengths of the first two/three components to the
> attribute table?
>
> For a quick fix, I solved the problem in a shell script using
> a crude approximation. FWIW:
> 0. Set major axis length=-1
> 1. Rotate polygon by 10° (v.transform)
> 2. Fit region to polygon (g.region vect=).
> 3. Get width of region. If it is greater than major axis length,
>    set "major axis length = width"
> 4. Repeat from 1, until polygon has been rotated 350°
> 5. Minor axis length = height of current region.

Wow, What a smart approach! :-)

Nikos


More information about the grass-user mailing list