gemgis.vector.extract_xy_linestring#

gemgis.vector.extract_xy_linestring(gdf: geopandas.geodataframe.GeoDataFrame, target_crs: Union[str, pyproj.crs.crs.CRS] = None, bbox: Optional[Sequence[float]] = None) geopandas.geodataframe.GeoDataFrame#

Extracting the coordinates of Shapely LineStrings within a GeoDataFrame and storing the X and Y coordinates in lists per LineString

Parameters
  • gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame created from vector data containing elements of geom_type LineString

  • target_crs (Union[str, pyproj.crs.crs.CRS]) – Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g. target_crs='EPSG:4647'

  • bbox (Optional[Sequence[float]]) – Values (minx, maxx, miny, maxy) to limit the extent of the data, e.g. bbox=[0, 972, 0, 1069]

Returns

gdf – GeoDataFrame containing the additional X and Y columns with lists of X and Y coordinates

Return type

gpd.geodataframe.GeoDataFrame

New in version 1.0.x.

Example

>>> # Loading Libraries and File
>>> import gemgis as gg
>>> import geopandas as gpd
>>> gdf = gpd.read_file(filename='file.shp')
>>> gdf
    id      formation   geometry
0       None    Sand1       LINESTRING (0.256 264.862, 10.593 276.734, 17....
1       None    Ton         LINESTRING (0.188 495.787, 8.841 504.142, 41.0...
2       None    Ton         LINESTRING (970.677 833.053, 959.372 800.023, ...
>>> # Extracting X and Y Coordinates from LineString Objects
>>> gdf_xy = gg.vector.extract_xy_linestring(gdf=gdf)
>>> gdf_xy
    id      formation   geometry                                                X                                                       Y
0       None    Sand1       LINESTRING (0.256 264.862, 10.593 276.734, 17....   [0.256327195431048, 10.59346813871597, 17.1349...       [264.86214748436396, 276.73370778641777, 289.0...
1       None    Ton         LINESTRING (0.188 495.787, 8.841 504.142, 41.0...   [0.1881868620686138, 8.840672956663411, 41.092...       [495.787213546976, 504.1418419288791, 546.4230...
2       None    Ton         LINESTRING (970.677 833.053, 959.372 800.023, ...   [970.6766251230017, 959.3724321757514, 941.291...       [833.052616499831, 800.0232029873156, 754.8012...

See also

extract_xy_linestrings

Extracting X and Y coordinates from a GeoDataFrame containing Shapely LineStrings

extract_xy_points

Extracting X and Y coordinates from a GeoDataFrame containing Shapely Points

extract_xy

Extracting X and Y coordinates from Vector Data