shapely.coverage_union

Contents

shapely.coverage_union#

coverage_union(a, b, **kwargs)#

Merge multiple polygons into one.

This is an optimized version of union which assumes the polygons to be non-overlapping. If this assumption is not met, the exact result is not guaranteed (depending on the GEOS version, it may return the input unchanged or raise an error).

Parameters:
a, bGeometry or array_like

Geometry or geometries to merge (union).

**kwargs

See NumPy ufunc docs for other keyword arguments.

Examples

>>> import shapely
>>> from shapely import Polygon
>>> polygon_1 = Polygon([(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)])
>>> polygon_2 = Polygon([(1, 0), (1, 1), (2, 1), (2, 0), (1, 0)])
>>> shapely.coverage_union(polygon_1, polygon_2).normalize()
<POLYGON ((0 0, 0 1, 1 1, 2 1, 2 0, 1 0, 0 0))>

Union with None returns same polygon

>>> shapely.coverage_union(polygon_1, None).normalize()
<POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))>