gemgis.vector.explode_polygon
gemgis.vector.explode_polygon#
- gemgis.vector.explode_polygon(polygon: shapely.geometry.polygon.Polygon) List[shapely.geometry.point.Point] #
Exploding Shapely Polygon to list of Points
- Parameters
polygon (shapely.geometry.polygon.Polygon) – Shapely Polygon from which vertices are extracted, e.g.
polygon = Polygon([(0, 0), (1, 1), (1, 0)])
- Returns
point_list – List containing the vertices of a polygon as Shapely Points
- Return type
List[shapely.geometry.point.Point]
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Polygon >>> import gemgis as gg >>> from shapely.geometry import Polygon >>> polygon = Polygon([(0, 0), (1, 1), (1, 0)]) >>> polygon.wkt 'POLYGON ((0 0, 1 1, 1 0, 0 0))'
>>> # Exploding Polygon into single Points >>> polygon_exploded = gg.vector.explode_polygon(polygon=polygon) >>> polygon_exploded [<shapely.geometry.point.Point at 0x201459734f0>, <shapely.geometry.point.Point at 0x20145973670>, <shapely.geometry.point.Point at 0x20145973640>, <shapely.geometry.point.Point at 0x201459732e0>]
>>> # Inspecting the first element of the list >>> polygon_exploded[0].wkt 'POINT (0 0)'
>>> # Inspecting the second element of the list >>> polygon_exploded[1].wkt 'POINT (1 1)'
See also
explode_polygons
Exploding a GeoDataFrame containing Polygons into a GeoDataFrame containing LineStrings