shapely.boundary

Contents

shapely.boundary#

boundary(geometry, **kwargs)#

Returns the topological boundary of a geometry.

Parameters:
geometryGeometry or array_like

This function will return None for geometrycollections.

**kwargs

See NumPy ufunc docs for other keyword arguments.

Examples

>>> from shapely import GeometryCollection, LinearRing, LineString, MultiLineString, MultiPoint, Point, Polygon
>>> boundary(Point(0, 0))
<GEOMETRYCOLLECTION EMPTY>
>>> boundary(LineString([(0, 0), (1, 1), (1, 2)]))
<MULTIPOINT ((0 0), (1 2))>
>>> boundary(LinearRing([(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)]))
<MULTIPOINT EMPTY>
>>> boundary(Polygon([(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)]))
<LINESTRING (0 0, 1 0, 1 1, 0 1, 0 0)>
>>> boundary(MultiPoint([(0, 0), (1, 2)]))
<GEOMETRYCOLLECTION EMPTY>
>>> boundary(MultiLineString([[(0, 0), (1, 1)], [(0, 1), (1, 0)]]))
<MULTIPOINT ((0 0), (0 1), (1 0), (1 1))>
>>> boundary(GeometryCollection([Point(0, 0)])) is None
True