cartagen.polygon_compactness

cartagen.polygon_compactness#

polygon_compactness(polygon)#

Calculate the compactness of a polygon.

This function calculates the compactness of a polygon using the Miller index. This index gives a maximum value of 1 for circles.

Parameters:

polygon (Polygon) – The polygon to calculated the compactness from.

Returns:

float

Notes

The Miller index is calculated using \((4·pi·area)/(perimeter^2)\)

Examples

>>> polygon = Polygon([(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)])
>>> polygon_compactness(polygon)
0.7853981633974483

(Source code)