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

Benjamin Ducke benducke at fastmail.fm
Mon Nov 24 13:50:46 PST 2014


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.

Like I said, it's just a crude approximation (precision can
be increased by using smaller rotation steps) and slow, too.
But it's good enough for my purposes, which is basically to
calculate "elongation=len(major)/len(min)".

Best,

Ben

On 24/11/14 19:27, Sören Gebbert wrote:
> IIRC is the code to compute the major and minor axes already in GRASS.
> You need to perform a Karhunen-Loewe-Transformation for each Polygon.
> This is also known as principal components analysis.
> 
> Best regards
> Soeren
> 
> Am 21.11.2014 23:33 schrieb "Benjamin Ducke" <benducke at fastmail.fm
> <mailto:benducke at fastmail.fm>>:
> 
>     Hi All --
> 
>     Does anybody here know of an existing GRASS modules that
>     will compute the major and minor axes for the polygons of
>     a vector map?
> 
>     Thanks and best,
> 
>     Ben
>     _______________________________________________
>     grass-user mailing list
>     grass-user at lists.osgeo.org <mailto:grass-user at lists.osgeo.org>
>     http://lists.osgeo.org/mailman/listinfo/grass-user
> 



-- 
Dr. Benjamin Ducke
{*} Geospatial Consultant
{*} GIS Developer

Spatial technology for the masses, not the classes:
experience free and open source GIS at http://gvsigce.org


More information about the grass-user mailing list