shapely.disjoint_subset_union#
- disjoint_subset_union(a, b, **kwargs)#
Merge multiple polygons into one using algorithm optimised for subsets.
Note
‘disjoint_subset_union’ 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()
. As such, it is recommeded to usedisjoint_subset_union
with GeometryCollections rather than individual geometries.Added in version 2.1.0.
- Parameters:
- a, bGeometry or array_like
Geometry or geometries to merge (union).
- **kwargs
See NumPy ufunc docs for other keyword arguments.
See also
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(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.disjoint_subset_union(polygon_1, None).normalize() <POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))>