cartagen.close_polygon

Contents

cartagen.close_polygon#

close_polygon(polygon, size, quad_segs=1)#

Close a polygon using dilation and erosion.

This algorithm relies on the successive dilation and erosion of polygon to merge close polygons together and simplify their complexity.

Parameters:
  • polygon (Polygon or MultiPolygon) – The polygon to close.

  • size (float) – The size of the dilation and erosion.

  • quad_segs (int) – The number of linear segments in a quarter circle when performing the buffer. If above 1, the result may have round corners unsuitable for buildings.

Returns:

Polygon or MultiPolygon

See also

open_polygon

Open a polygon using erosion and dilation.

Examples

>>> polygon = Polygon([(1, 1), (1, 2), (2, 2), (2, 0), (1, 1)])
>>> close_polygon(polygon, 1)
<POLYGON ((1.1508574748015223 1.2059024350708356, 1.5586467790767369 1.1617820026014096, 1.4159303795947187 1.5899312010474647, 1.1111173768873637 1.4375246996937872, 1.1508574748015223 1.2059024350708356))>

(Source code)

../_images/close_polygon.png