cartagen.surfacic_distance

cartagen.surfacic_distance#

surfacic_distance(polygon1, polygon2)#

Calculate the surfacic distance between two polygons.

The surfacic distance is a distance between 0 and 1 using the intersection over union principle. 0 means the two polygons share the same footprint. 1 means the two polygons doesn’t overlap.

Parameters:
  • polygon1 (Polygon) – The first polygon to calculate the distance from.

  • polygon2 (Polygon) – The second polygon in the distance calculation

Returns:

float

Examples

>>> polygon1 = Polygon([(0, 0), (0, 2), (1, 2), (1, 0), (0, 0)])
>>> polygon1 = Polygon([(0, 1), (0, 4), (1, 4), (1, 1), (0, 1)])
>>> surfacic_distance(polygon1, polygon2)
0.75