gemgis.vector.create_linestrings_from_xyz_points#

gemgis.vector.create_linestrings_from_xyz_points(gdf: geopandas.geodataframe.GeoDataFrame, groupby: str, nodata: Union[int, float] = 9999.0, xcol: str = 'X', ycol: str = 'Y', zcol: str = 'Z', dem: Union[numpy.ndarray, rasterio.io.DatasetReader] = None, extent: List[Union[int, float]] = None, return_gdf: bool = True, drop_nan: bool = True) Union[List[shapely.geometry.linestring.LineString], geopandas.geodataframe.GeoDataFrame]#

Creating LineStrings from a GeoDataFrame containing X, Y, and Z coordinates of vertices of multiple LineStrings

Parameters
  • gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing extracted X, Y, and Z coordinates of LineStrings

  • groupby (str) – Name of a unique identifier the LineStrings can be separated from each other, e.g. groupby='Object_ID'

  • nodata (Union[int, float])) – Nodata value to filter out points outside a designated area, e.g. nodata=9999.0, default is 9999.0

  • xcol (str) – Name of the X column in the dataset, e.g. xcol='X', default is 'X'

  • ycol (str) – Name of the Y column in the dataset, e.g. ycol='Y', default is 'Y'

  • zcol (str) – Name of the Z column in the dataset, e.g. zcol='Z', default is 'Z'

  • dem (Union[np.ndarray, rasterio.io.DatasetReader]) – NumPy ndarray or rasterio object containing the height values, default value is None in case geometries contain Z values

  • extent (List[Union[float, int]]) – Values for minx, maxx, miny and maxy values to define the boundaries of the raster, e.g. extent=[0, 972, 0, 1069]

  • return_gdf (bool) – Variable to either return the data as GeoDataFrame or as list of LineStrings. Options include: True or False, default set to True

  • drop_nan (bool) – Boolean argument to drop points that contain a nan value as Z value. Options include True and False, default is True

Returns

linestrings – List of LineStrings or GeoDataFrame containing the LineStrings with Z component

Return type

Union[List[shapely.geometry.linestring.LineString], gpd.geodataframe.GeoDataFrame]

New in version 1.0.x.

Changed in version 1.1: Removed manual dropping of additional columns. Now automatically drops unnecessary coloumns. Adding argument drop_nan and code to drop coordinates that contain nan values as Z coordinates.

Example

>>> # Loading Libraries and File
>>> import gemgis as gg
>>> import geopandas as gpd
>>> gdf = gpd.read_file(filename='file.shp')
>>> gdf
>>> # Creating LineStrings with Z component from gdf
>>> gdf_linestring = gg.vector.create_linestrings_from_xyz_points(gdf=gdf, groupby='ABS')
>>> gdf_linestring