shapely.disjoint_subset_union_all

shapely.disjoint_subset_union_all#

disjoint_subset_union_all(geometries, *, axis=None, **kwargs)#

Return the union of multiple polygons.

Note

‘disjoint_subset_union_all’ requires at least GEOS 3.12.0.

This is an optimized version of union which assumes inputs can be divided into subsets that do not intersect.

If there is only one such subset, performance can be expected to be worse than union_all().

This function ignores None values when other Geometry elements are present. If all elements of the given axis are None, an empty GeometryCollection is returned.

Added in version 2.1.0.

Parameters:
geometriesarray_like

Geometries to union.

axisint, optional

Axis along which the operation is performed. The default (None) performs the operation over all axes, returning a scalar value. Axis may be negative, in which case it counts from the last to the first axis.

**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.disjoint_subset_union_all([polygon_1, polygon_2]).normalize()
<POLYGON ((0 0, 0 1, 1 1, 2 1, 2 0, 1 0, 0 0))>
>>> shapely.disjoint_subset_union_all([polygon_1, None]).normalize()
<POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))>
>>> shapely.disjoint_subset_union_all([None, None]).normalize()
<GEOMETRYCOLLECTION EMPTY>