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

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

On 21/11/14 23:19, Benjamin Ducke wrote:

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?

I don't know how you define these axes for a polygon, but I imagine that v.voronoi's '-s' flag might help you (grass7); at least for the major axis.

Moritz

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@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@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

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@fastmail.fm
<mailto:benducke@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@lists.osgeo.org <mailto:grass-user@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

Hi Ben,

2014-11-24 22:50 GMT+01:00 Benjamin Ducke <benducke@fastmail.fm>:

Right, a PCA of the polygon vertices, I assume?

Exactly, create a covariance matrix from the vertices coordinates of
each polygon
and compute the eigenvectors and eigenvalues of these matrices.

Best regards
Soeren

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@fastmail.fm
<mailto:benducke@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@lists.osgeo.org <mailto:grass-user@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
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

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! :slight_smile:

Nikos