bg_overlay_polygon

geometric-functions bg_overlay_polygon

syntax

  • bg_overlay_polygon (first_polygon_data_item, second_polygon_data_item)

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.

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

  1. The composition type of the first_polygon_data_item and second_polygon_data arguments needs to be a polygon with an ipoint, spoint, fpoint, or dpoint value-type.
  2. The values-unit of the first_polygon_data_item and second_polygon_data arguments items must match.
  3. The order of the points in the first_polygon_data_item and second_polygon_data 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);