Create polygons formed from the linework of a set of Geometries. 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 outp
(geometries, **kwargs)
| 893 | |
| 894 | |
| 895 | def polygonize(geometries, **kwargs): |
| 896 | """Create polygons formed from the linework of a set of Geometries. |
| 897 | |
| 898 | Polygonizes an array of Geometries that contain linework which |
| 899 | represents the edges of a planar graph. Any type of Geometry may be |
| 900 | provided as input; only the constituent lines and rings will be used to |
| 901 | create the output polygons. |
| 902 | |
| 903 | Lines or rings that when combined do not completely close a polygon |
| 904 | will result in an empty GeometryCollection. Duplicate segments are |
| 905 | ignored. |
| 906 | |
| 907 | This function returns the polygons within a GeometryCollection. |
| 908 | Individual Polygons can be obtained using ``get_geometry`` to get |
| 909 | a single polygon or ``get_parts`` to get an array of polygons. |
| 910 | MultiPolygons can be constructed from the output using |
| 911 | ``shapely.multipolygons(shapely.get_parts(shapely.polygonize(geometries)))``. |
| 912 | |
| 913 | Parameters |
| 914 | ---------- |
| 915 | geometries : array_like |
| 916 | An array of geometries. |
| 917 | axis : int |
| 918 | Axis along which the geometries are polygonized. |
| 919 | The default is to perform a reduction over the last dimension |
| 920 | of the input array. A 1D array results in a scalar geometry. |
| 921 | **kwargs |
| 922 | See :ref:`NumPy ufunc docs <ufuncs.kwargs>` for other keyword arguments. |
| 923 | |
| 924 | Returns |
| 925 | ------- |
| 926 | GeometryCollection or array of GeometryCollections |
| 927 | |
| 928 | See Also |
| 929 | -------- |
| 930 | get_parts, get_geometry |
| 931 | polygonize_full |
| 932 | node |
| 933 | |
| 934 | Examples |
| 935 | -------- |
| 936 | >>> import shapely |
| 937 | >>> from shapely import LineString |
| 938 | >>> lines = [ |
| 939 | ... LineString([(0, 0), (1, 1)]), |
| 940 | ... LineString([(0, 0), (0, 1)]), |
| 941 | ... LineString([(0, 1), (1, 1)]) |
| 942 | ... ] |
| 943 | >>> shapely.polygonize(lines) |
| 944 | <GEOMETRYCOLLECTION (POLYGON ((1 1, 0 0, 0 1, 1 1)))> |
| 945 | |
| 946 | """ |
| 947 | return lib.polygonize(geometries, **kwargs) |
| 948 | |
| 949 | |
| 950 | def polygonize_full(geometries, **kwargs): |
searching dependent graphs…