gemgis.vector.extract_xyz_linestrings
gemgis.vector.extract_xyz_linestrings#
- gemgis.vector.extract_xyz_linestrings(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 LineStrings with Z components
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing Shapely LineStrings 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 LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> import geopandas as gpd >>> linestring = LineString(([1,2,3], [4,5,6])) >>> linestring.wkt 'LINESTRING Z (1 2 3, 4 5 6)'
>>> # Creating GeoDataFrame from LineString >>> gdf = gpd.GeoDataFrame(geometry=[linestring, linestring]) >>> gdf geometry 0 LINESTRING Z (1.00000 2.00000 3.00000, 4.00000... 1 LINESTRING Z (1.00000 2.00000 3.00000, 4.00000...
>>> # Extracting X, Y, and Z Coordinates from Point Objects >>> gdf = gg.vector.extract_xyz_linestrings(gdf=gdf) >>> gdf geometry points X Y Z 0 POINT (1.00000 2.00000) (1.0, 2.0, 3.0) 1.00 2.00 3.00 1 POINT (4.00000 5.00000) (4.0, 5.0, 6.0) 4.00 5.00 6.00 2 POINT (1.00000 2.00000) (1.0, 2.0, 3.0) 1.00 2.00 3.00 3 POINT (4.00000 5.00000) (4.0, 5.0, 6.0) 4.00 5.00 6.00
See also
extract_xyz_points
Extracting X and Y coordinates from a GeoDataFrame containing Shapely Points with Z components
extract_xyz_polygons
Extracting X and Y coordinates from a GeoDataFrame containing Shapely Polygons with Z component