gemgis.vector.extract_xyz_polygons
gemgis.vector.extract_xyz_polygons#
- gemgis.vector.extract_xyz_polygons(gdf: geopandas.geodataframe.GeoDataFrame, reset_index: bool = True, drop_index: bool = True) geopandas.geodataframe.GeoDataFrame #
Extracting X, Y, and Z coordinates from a GeoDataFrame containing Shapely Polygons with Z components
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing Shapely Polygons with X, Y, and Z components
reset_index (bool) – Variable to reset the index of the resulting GeoDataFrame. Options include:
True
orFalse
, default set toTrue
drop_index (bool) – Variable to drop the index column. Options include:
True
orFalse
, default set toTrue
- Returns
gdf – GeoDataFrame containing Shapely Points with appended X, Y, and Z columns
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Shapely Polygon >>> import gemgis as gg >>> from shapely.geometry import Polygon >>> import geopandas as gpd >>> polygon = Polygon([[0, 0, 1], [1, 0, 1], [1, 1, 1], [0, 1, 1], [0, 0, 1]]) >>> polygon.wkt 'POLYGON Z ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1))'
>>> # Creating GeoDataFrame from LineString >>> gdf = gpd.GeoDataFrame(geometry=[polygon, polygon]) >>> gdf geometry 0 POLYGON Z ((0.00000 0.00000 1.00000, 1.00000 0... 1 POLYGON Z ((0.00000 0.00000 1.00000, 1.00000 0...
>>> # Extracting X, Y, and Z Coordinates from Point Objects >>> gdf = gg.vector.extract_xyz_polygons(gdf=gdf) >>> gdf geometry points X Y Z 0 POINT (0.00000 0.00000) [0.0, 0.0, 1.0] 0.00 0.00 1.00 1 POINT (1.00000 0.00000) [1.0, 0.0, 1.0] 1.00 0.00 1.00 2 POINT (1.00000 1.00000) [1.0, 1.0, 1.0] 1.00 1.00 1.00 3 POINT (0.00000 1.00000) [0.0, 1.0, 1.0] 0.00 1.00 1.00
See also
extract_xyz_points
Extracting X and Y coordinates from a GeoDataFrame containing Shapely Points with Z component
extract_xyz_linestrings
Extracting X and Y coordinates from a GeoDataFrame containing Shapely LineStrings with Z components