cartagen.polygon_orientation

cartagen.polygon_orientation#

polygon_orientation(polygon, method='mbr')#

Calculate the orientation of a polygon.

This function calculates the orientation of a polygon using different methods. By default, it uses the orientation of the long side of the minimum bounding rectangle.

Parameters:
  • polygon (Polygon) – The polygon to calculate the orientation from.

  • method (str, optional) –

    The method to calculate the orientation:

    • ’primary’ calculates the orientation of the longest side of the provided polygon.

    • ’mbr’ calculates the orientation of the long side of the minimum rotated bounding rectangle.

    • ’mbtr’ calculates the orientation of the long side of the minimum rotated bounding touching rectangle. It is the same as the mbr but the rectangle and the polygon must have at least one side in common.

    • ’swo’ or statistical weighted orientation described in Duchêne, [1] calculates the orientation of a polygon using the statistical weighted orientation. This method relies on the length and orientation of the longest and second longest segment between two vertexes of the polygon.

Returns:

float

References

Examples

>>> polygon = Polygon([(0, 0), (0, 2), (1, 2), (1, 0), (0, 0)])
>>> polygon_orientation(polygon)
1.5707963267948966