bg_overlay_polygon
Geometric functions bg_overlay_polygon

syntax
- bg_overlay_polygon (first_polygon_data_item, second_polygon_data_item)
- bg_overlay_polygon (polygon_data_item): the pairs within one polygon set, each pair once (first_rel < second_rel), with their intersection geometry. Since GeoDMS 15.7.0.
description
bg_overlay_polygon(first_polygon_data_item, second_polygon_data_item) results in a new uint32 Domain unit with an entry for each intersecting part of the first_polygon_data_item and the second_polygon_data_item.
The function generates three subitems for the new domain unit:
- geometry: the Geometry of the resulting polygons (in the figure the yellow polygons). This Attribute has the same Values unit as the first_polygon_data_item and second_polygon_data_item attributes.
- first_rel: a relation for the new domain unit towards the domain of the first_polygon_data_item.
- second_rel: a relation for the new domain unit towards the domain of the second_polygon_data_item.
In QGIS, this operation is known as intersect.
Two polygons form a pair when their intersection has an area, that is when they have a common interior point. Polygons that only touch, along a shared edge or at a single point, are not a pair; geos_overlay_polygon differs there. When only the pairing is needed and not the geometry, bg_polygon_connectivity finds the same pairs as relations only.
It is similar to:
unit<uint32> CartesianProduct := combine(DomainUnit(first_polygon_data_item), DomainUnit(second_polygon_data_item))
{
attribute<ValuesUnit(first_polygon_data_item)> Geometry(poly) := first_polygon_data_item[first_rel] * second_polygon_data_item[second_rel];
attribute<bool> IsIntersecting := area(Geometry, float64) > 0.0;
}
unit<uint32> result := select(CartesianProduct/IsIntersecting)
{
attribute<DomainUnit(first_polygon_data_item)> first_rel := collect_by_cond(., CartesianProduct/first_rel);
attribute<DomainUnit(second_polygon_data_item)> second_rel := collect_by_cond(., CartesianProduct/second_rel);
attribute<ValuesUnit(first_polygon_data_item)> Geometry(poly) := collect_by_cond(., CartesianProduct/Geometry);
}
conditions
- The composition type of the first_polygon_data_item and second_polygon_data_item arguments needs to be a polygon with an ipoint, spoint, fpoint, or dpoint Value type.
- The Values unit of the first_polygon_data_item and second_polygon_data_item arguments must match.
- The order of the points in the first_polygon_data_item and second_polygon_data_item needs to be clockwise for exterior bounds and counterclockwise for holes in polygons (right-hand-rule).
since version
15.6.0
example
unit<uint32> intersect := bg_overlay_polygon(Building/geometry, District/geometry);
see also
- bg_polygon_connectivity - the same pairs as relations only, without the intersection geometry
- geos_overlay_polygon, cgal_overlay_polygon, bp_overlay_polygon - the same operator on the other geometry libraries; the geos_ one also pairs polygons that only touch
- Polygon_connectivity - the unprefixed pairing within one set of integer coordinates, touching polygons included, with relations F1 and F2
- mul (polygon intersection) - the intersection of two polygons element by element, for pairs that are already known
- polygon operators - the comparison of the operators that find pairs of polygons
- dms_overlay_polygon - the same operator on the sweep GeoDMS implements itself, which accepts operands that are not valid polygons
- Spatial joins and allocation - the overlay as a spatial inner join