Skip to content

Polygon_connectivity

MaartenHilferink edited this page Sep 6, 2026 · 14 revisions

Geometric functions polygon_connectivity

syntax

  • polygon_connectivity(polygon_data_item)

definition

polygon_connectivity(polygon_data_item) results in a new uint32 domain unit with one entry for each 'connection' in the polygon_data_item argument.

Two polygons are connected when they overlap or touch: when they have a common interior point, share a boundary segment, or meet in a single boundary point. The operator is the connectivity extraction of the boost polygon library. To keep only the pairs that really overlap, intersect the two polygons of each pair and test the area, as the Spatial Overlap example does.

description

The function results in an F1 and F2 attribute with relations to the domain unit of the polygon_data_item attribute.

The relations indicate which connections exist, each connection only occurs once (a connection between polygon 0 and 1 only occurs as F1: 0 and F2: 1 and not vice versa).

Use the multiply operator for polygons to calculate the overlap between connected polygons.

The prefixed bp_polygon_connectivity, bg_polygon_connectivity, cgal_polygon_connectivity and geos_polygon_connectivity are a different implementation of the same idea, not a renaming of this operator: they also take two polygon sets, they name their relations first_rel and second_rel, and the bp_, bg_ and cgal_ ones require a common interior point, so a pair that only touches is not found there. Their xxx_overlay_polygon counterparts find the same pairs with the intersection geometry of each pair. The comparison is on polygon operators.

applies to

attribute polygon_data_item with an ipoint or spoint value type.

conditions

  1. The composition type type of the polygon_data_item argument needs to be polygon.
  2. The order of the points in polygon_data_item needs to be clockwise for exterior bounds and counter clockwise for holes in polygons (right-hand-rule).

since version

7.135

performance

O(n² * k) worst case where n = number of polygons and k = average polygon complexity. Uses spatial indexing to reduce comparisons in practice. Result size depends on connectivity of input polygons.

example

unit<uint32> connection := polygon_connectivity(district/geometry);
F1 F2
0 3
0 5
0 6
1 2
1 3
1 6
2 3
2 4
2 6
3 4
3 5
3 6
4 5

domain connection, nr of rows = 13

see also

Clone this wiki locally