gemgis.vector.create_linestring_from_xyz_points#

gemgis.vector.create_linestring_from_xyz_points(points: Union[numpy.ndarray, geopandas.geodataframe.GeoDataFrame], nodata: Union[int, float] = 9999.0, xcol: str = 'X', ycol: str = 'Y', zcol: str = 'Z', drop_nan: bool = True) shapely.geometry.linestring.LineString#

Create LineString from an array or GeoDataFrame containing X, Y, and Z coordinates of points.

Parameters
  • points (Union[np.ndarray, gpd.geodataframe.GeoDataFrame]) – NumPy Array or GeoDataFrame containing XYZ points.

  • 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'.

  • 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

line – LineString Z constructed from provided point values

Return type

shapely.geometry.linestring.LineString

New in version 1.0.x.

Changed in version 1.1: Adding argument drop_nan and code to drop coordinates that contain nan values as Z coordinates.

Example

>>> # Loading Libraries and creating points
>>> import gemgis as gg
>>> import numpy as np
>>> points = np.array([[3.23, 5.69, 2.03],[3.24, 5.68, 2.02],[3.25, 5.67, 1.97],[3.26, 5.66, 1.95]])
>>> # Creating LineStrings from points
>>> linestring = gg.vector.create_linestring_from_xyz_points(points=points)
>>> linestring.wkt
'LINESTRING Z (3.23 5.69 2.03, 3.24 5.68 2.02, 3.25 5.67 1.97, 3.26 5.66 1.95)'