polygon operators - ObjectVision/GeoDMS GitHub Wiki

Back to Geometric functions


  • area - calculates the surface area of each polygon
  • centroid - center of mass of each polygon
  • mid - a point in the polygon, cheaper than centroid
  • outer_single_polygon - outer ring of a single polygon (drops holes)
  • outer_multi_polygon - outer ring(s) of each multi_polygon (drops the holes)
  • geos_buffer - buffer of a (multi)polygon, geos implementation
  • canyon - street-canyon heights for road points from surrounding heights
  • centroid_or_mid - the centroid if located within the polygon, otherwise a mid-point
  • poly2grid - a grid representation of polygons
  • poly2grid_untiled - a grid representation of polygons (untiled variant)
  • poly2allgrids - a cross-table representation of polygons and raster cells
  • poly2allgrids_uint64 - a uint64 cross-table representation of polygons and raster cells
  • lower_bound - the lowest X and Y values of the points in each polygon
  • upper_bound - the highest X and Y values of the points in each polygon
  • center_bound - the center X and Y values of the points in each polygon
  • points2polygon - create polygons from sequences of points
  • sub (difference) - element-wise cutout of one polygon from another, where both domains match or one is void
  • mul (polygon intersection) - element-wise overlap of two polygon arrays, where both domains match or one is void
  • add (union) - element-wise union of two polygon arrays, where both domains match or one is void
  • box_connectivity - find connected polygons based on bounding box overlap (faster, but less precise than polygon_connectivity)

Ring order (winding) operators:

  • reverse_polygon - reverse the winding order of every ring, without changing the sequence layout
  • fix_winding_order - give every ring the clockwise-outer / counter-clockwise-hole order, deriving the ring roles from their nesting; repairs half-flipped multi-polygons that a reversal cannot
  • has_correct_winding - True for each element whose ring order is certifiably correct; the replacement for the area(g) < 0 test, which misses a half-flipped feature
  • [fix_polygon]] - [[fix_winding_order]] plus repair of self-intersections and other invalidity ([GEOS MakeValid)

Operators based on the geos library (recommended: faster, reliable, supports float64/dpoint coordinates):

  • geos_buffer_multi_polygon - creates a buffer polygon for each multi polygon
  • geos_difference - element-wise difference of two polygon arrays (A minus B); also invoked by the - operator for fpoint/dpoint coordinates
  • geos_intersect - element-wise intersection of two polygon arrays; also invoked by the * and & operators for fpoint/dpoint coordinates
  • geos_minkowski_sum - grow each geometry by a kernel: the kernel as a polygon argument, or one of six named shapes at a given size
  • geos_minkowski_difference - shrink each geometry by a kernel; the eroding counterpart
  • geos_overlay_polygon - spatial overlay between two polygon datasets, producing all intersecting pairs with their intersection geometry
  • [geos_polygon]] - clean and validate polygon geometry using [GEOS
  • geos_polygon_connectivity - find all pairs of adjacent or overlapping polygons
  • geos_simplify_multi_polygon - simplify the geometry of a multi polygon
  • geos_split_polygon - split multi-polygons into individual single-polygon parts, each as a separate domain entry
  • geos_split_union_polygon - dissolve polygons (optionally grouped by attribute), then split into individual parts
  • geos_union - element-wise union of two polygon arrays; also invoked by the + and | operators for fpoint/dpoint coordinates
  • geos_union_polygon - dissolve all polygons into one, optionally grouped by a partition attribute
  • geos_xor - element-wise symmetric difference of two polygon arrays; also invoked by the ^ operator for fpoint/dpoint coordinates

To be potentially developed operators:

Operators based on the boost polygon library (usually slower than the bg_-variants, and can only process integer coordinates):

  • bp_buffer_multi_polygon - removed in 20.13.0: never implemented; use bg_buffer_multi_polygon or geos_buffer_multi_polygon
  • bp_difference - element-wise difference of two polygon arrays (integer coordinates)
  • bp_intersect - element-wise intersection of two polygon arrays (integer coordinates)
  • bp_overlay_polygon (or old syntax overlay_polygon) - spatial overlay between two polygon datasets, producing all intersecting pairs (integer coordinates)
  • bp_polygon - clean and validate polygon geometry using Boost Polygon (integer coordinates)
  • bp_polygon_connectivity (or old syntax polygon_connectivity) - find all pairs of adjacent or overlapping polygons (integer coordinates)
  • bp_split_polygon (or old syntax split_polygon) - split multi-polygons into individual single-polygon parts (integer coordinates)
  • [bp_split_union_polygon]] (or old syntax [[split_partitioned_union_polygon]]) - dissolve polygons (optionally grouped by attribute), then split into individual parts (integer coordinates). Combination of [[split_polygon]] and [partitioned_union_polygon
  • bp_union - element-wise union of two polygon arrays (integer coordinates)
  • bp_union_polygon (or old syntax union_polygon (dissolve) or partitioned_union_polygon (dissolve by attribute)) - dissolve all polygons into one, optionally grouped by a partition attribute (integer coordinates)
  • bp_polygon_filtered, bp_union_polygon_filtered, bp_split_polygon_filtered, bp_split_union_polygon_filtered - bp-set operations that drop rings smaller than the given area
  • bp_polygon_inflated, bp_union_polygon_inflated, bp_split_polygon_inflated, bp_split_union_polygon_inflated - bp-set operations after growing the polygons with the given distance
  • bp_polygon_deflated, bp_union_polygon_deflated, bp_split_polygon_deflated, bp_split_union_polygon_deflated - bp-set operations after shrinking the polygons with the given distance
  • bp_minkowski_sum - grow each geometry by a kernel: the kernel as a polygon argument, or one of six named shapes at a given size
  • bp_minkowski_difference - shrink each geometry by a kernel; the eroding counterpart
  • bp kernel-suffix variants - DEPRECATED since 20.18.0: the 48 names bp_polygon_i4HVbp_split_union_polygon_dXD (12 kernels x {plain, union, split, split_union}) that carried the kernel shape in the operator name. They still work but warn, naming the replacement. The kernel is an argument now: use bp_minkowski_sum / bp_minkowski_difference on the result of the same operator without the suffix. See the migration table on Boost polygon functions.
  • bp_xor - element-wise symmetric difference of two polygon arrays (integer coordinates)
  • polygon inflated - increases each polygon by expanding its boundary outward
  • polygon deflated - decreases each polygon by contracting its boundary inward

Several boost polygon functions can be combined in a single operator; for the full list of those combinations, see here.

Operators based on the boost geometry library (float64/dpoint coordinates; largely superseded by their geos equivalents):

For examples, see here.

Operators based on the cgal library:

  • cgal_difference - element-wise difference of two polygon arrays (CGAL)
  • cgal_intersect - element-wise intersection of two polygon arrays (CGAL)
  • cgal_minkowski_sum - grow each geometry by a kernel, through CGAL::minkowski_sum_2: the exact one of the four backends
  • cgal_minkowski_difference - shrink each geometry by a kernel; the eroding counterpart
  • cgal_overlay_polygon - spatial overlay between two polygon datasets, producing all intersecting pairs (CGAL)
  • cgal_polygon - clean and validate polygon geometry using CGAL
  • cgal_polygon_connectivity - find all pairs of adjacent or overlapping polygons (CGAL)
  • cgal_split_polygon - split multi-polygons into individual single-polygon parts (CGAL)
  • cgal_split_union_polygon - dissolve polygons (optionally grouped by attribute), then split into individual parts (CGAL)
  • cgal_union - element-wise union of two polygon arrays (CGAL)
  • cgal_union_polygon - dissolve all polygons into one, optionally grouped by a partition attribute (CGAL)
  • cgal_xor - element-wise symmetric difference of two polygon arrays (CGAL)