Skip to content

Polygon filtered

MaartenHilferink edited this page Jun 14, 2026 · 1 revision

Geometric functions polygon filtered

syntax

  • polygon_filtered(polygon_data_item, minArea)
  • prefix_polygon_filtered(polygon_data_item, minArea)
  • prefix[split][[partitioned_]union_]polygon_filtered(polygon_data_item[, partitioning], minArea)

where prefix is one of bp_, bg_, cgal_ or geos_.

description

The _filtered suffix removes small polygons from the result: it keeps only the polygons (and polygon parts) whose area is at least minArea, and drops everything smaller. Internally the Boost Polygon keep operation is used with minArea as the lower area bound.

It is one of the three polygon modifier suffixes, applied on top of the base polygon cleaning / dissolve operators:

  • _filtered - drop polygons with area below minArea (this page).
  • _inflated - grow polygons, see polygon inflated.
  • _deflated - shrink polygons, see polygon deflated.

The modifiers are available on every member of the polygon family: the plain polygon cleaner, union_polygon (dissolve), partitioned_union_polygon (dissolve by attribute) and their split_ variants, each with a bp_ / bg_ / cgal_ / geos_ prefix. For example bp_union_polygon_filtered dissolves and then removes the small resulting polygons.

requirements

  • attribute polygon_data_item with a point value type with integer coordinates (ipoint or spoint) and composition type polygon.
  • parameter minArea with a float64 value type, expressed in squared units of the coordinate system (an area). Polygons with a smaller area are removed.
  • the optional partitioning argument (only for the partitioned_union_ variants) is a relation indicating per-polygon the partition to dissolve within.

As for the other Boost Polygon modifiers, coordinate values must stay below 2^25 (≈ 33 [km] when coordinates are in mm) after the first point is translated to (0, 0); convert to a coarser unit (cm/dm) for large extents.

combining suffixes

_filtered can be combined with _inflated or _deflated in a single operator. The rule is simple:

  • the suffix order equals the operation order (left to right), and
  • the numeric arguments follow in that same order.
operator operations extra arguments
..polygon_filtered filter minArea
..polygon_filtered_inflated filter, then inflate minArea, increment
..polygon_deflated_filtered deflate, then filter decrement, minArea
..polygon_inflated_filtered inflate, then filter increment, minArea
..polygon_filtered_deflated filter, then deflate minArea, decrement

So bg_polygon_deflated_filtered(geometry, 5d, 100d) first deflates the polygons by 5, then removes the resulting polygons with an area below 100. A maximum of two modifiers can be combined.

since version

8.041

example

// keep only polygons with an area of at least 1000 (squared coordinate units)
attribute<ipoint> big_districts (polygon, district) := bp_polygon_filtered(district/geometry, 1000d);

// dissolve neighbouring polygons, then drop the small slivers
attribute<ipoint> dissolved_clean (polygon, region) := bp_union_polygon_filtered(district/geometry, 1000d);

// deflate by 5, then remove polygons that became too small
attribute<ipoint> eroded (polygon, district) := bp_polygon_deflated_filtered(district/geometry, 5d, 250d);

see also

Clone this wiki locally