Interactive polygon comparison

This interactive visualization compares two complementary metrics for polygon similarity:

PoLiS (Polygon-to-Line-Segment) distance [1] measures the average distance between vertices of one polygon and the boundary of another polygon. The metric is computed as: $$\text{PoLiS}(A,B) = \frac{1}{2} \left( \frac{1}{|A|}\sum_{a_j \in A} \text{dist}(a_j, \partial B) + \frac{1}{|B|}\sum_{b_k \in B} \text{dist}(b_k, \partial A) \right)$$ where \(\text{dist}(a_j, \partial B)\) is the shortest distance from vertex \(a_j\) to any edge of polygon \(B\). Properties of PoLiS (copied from [1]):
  • Compares polygons, not only point sets, with different numbers of vertices
  • Insensitive to additional points on polygon edges
  • Monotonic with linear response to small changes in translation, rotation, and scale
  • A true metric in the mathematical sense (satisfies triangle inequality)
[1] Avbelj, J., Müller, R., & Bamler, R. (2014). A metric for polygon comparison and building extraction evaluation. IEEE Geoscience and Remote Sensing Letters, 12(1), 170-174. [PDF]

IoU (Intersection over Union) measures the overlap between two polygons as the ratio of their intersection area to their union area: $$\text{IoU}(A,B) = \frac{\text{Area}(A \cap B)}{\text{Area}(A \cup B)} = \frac{\text{Area}(A \cap B)}{\text{Area}(A) + \text{Area}(B) - \text{Area}(A \cap B)}$$ IoU ranges from 0 (no overlap) to 1 (perfect overlap) and is widely used in object detection and segmentation tasks.

When they agree vs. differ: Both metrics detect large-scale misalignment and shape differences. However, PoLiS is more sensitive to positional shifts and boundary irregularities even when overlap remains high, while IoU primarily reflects area-based similarity and can remain stable despite shape deformations. Try rotating or translating the polygons slightly—you'll notice PoLiS increases while IoU may stay relatively constant.

Here the blue rectangle is polygon A and the purple polygon is polygon B. Drag and reshape B, or rotate A, to explore how both metrics respond.
Move inside the purple polygon to translate it; drag its vertices to reshape. Drag the small blue circle above the rectangle to rotate it. Toggle “Show nearest-distance rays” to visualize which boundary points are closest.
PoLiS distance (A,B)
0.00 px
IoU (Intersection over Union)
0.00
Avg distance A → B
0.00 px
Avg distance B → A
0.00 px
IoU vs PoLiS