shapely.polygonize_full

shapely.polygonize_full#

polygonize_full(geometries, **kwargs)#

Creates polygons formed from the linework of a set of Geometries and return all extra outputs as well.

Polygonizes an array of Geometries that contain linework which represents the edges of a planar graph. Any type of Geometry may be provided as input; only the constituent lines and rings will be used to create the output polygons.

This function performs the same polygonization as polygonize but does not only return the polygonal result but all extra outputs as well. The return value consists of 4 elements:

  • The polygonal valid output

  • Cut edges: edges connected on both ends but not part of polygonal output

  • dangles: edges connected on one end but not part of polygonal output

  • invalid rings: polygons formed but which are not valid

This function returns the geometries within GeometryCollections. Individual geometries can be obtained using get_geometry to get a single geometry or get_parts to get an array of geometries.

Parameters:
geometriesarray_like

An array of geometries.

axisint

Axis along which the geometries are polygonized. The default is to perform a reduction over the last dimension of the input array. A 1D array results in a scalar geometry.

**kwargs

See NumPy ufunc docs for other keyword arguments.

Returns:
(polygons, cuts, dangles, invalid)

tuple of 4 GeometryCollections or arrays of GeometryCollections

See also

polygonize

Examples

>>> from shapely import LineString
>>> lines = [
...     LineString([(0, 0), (1, 1)]),
...     LineString([(0, 0), (0, 1), (1, 1)]),
...     LineString([(0, 1), (1, 1)])
... ]
>>> polygonize_full(lines)  
(<GEOMETRYCOLLECTION (POLYGON ((1 1, 0 0, 0 1, 1 1)))>,
 <GEOMETRYCOLLECTION EMPTY>,
 <GEOMETRYCOLLECTION (LINESTRING (0 1, 1 1))>,
 <GEOMETRYCOLLECTION EMPTY>)