gemgis.vector.create_linestrings_from_contours#

gemgis.vector.create_linestrings_from_contours(contours: pyvista.core.pointset.PolyData, return_gdf: bool = True, crs: Union[str, pyproj.crs.crs.CRS] = None) Union[List[shapely.geometry.linestring.LineString], geopandas.geodataframe.GeoDataFrame]#

Creating LineStrings from PyVista Contour Lines and save them as list or GeoDataFrame

Parameters
  • contours (pv.core.pointset.PolyData) – PyVista PolyData dataset containing contour lines extracted from a mesh

  • return_gdf (bool) – Variable to create GeoDataFrame of the created list of Shapely Objects. Options include: True or False, default set to True

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

Returns

linestrings – List of LineStrings or GeoDataFrame containing the contours that were converted

Return type

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

New in version 1.0.x.

Example

>>> # Loading Libraries and File
>>> import gemgis as gg
>>> import pyvista as pv
>>> contours = pv.read('file.vtk')
>>> contours
Header
PolyData    Information
N Cells     36337
N Points    36178
X Bounds    3.233e+07, 3.250e+07
Y Bounds    5.704e+06, 5.798e+06
Z Bounds    -2.400e+03, 3.500e+02
N Arrays    1
Data Arrays
Name        Field   Type    N Comp  Min         Max
Depth [m]   Points  float64 1       -2.400e+03  3.500e+02
>>> # Extracting LineStrings from contours
>>> gdf = gg.vector.create_linestrings_from_contours(contours=contours)
>>> gdf
    geometry                                            Z
0   LINESTRING Z (32409587.930 5780538.824 -2350.0...   -2350.00
1   LINESTRING Z (32407304.336 5777048.086 -2050.0...   -2050.00
2   LINESTRING Z (32408748.977 5778005.047 -2200.0...   -2200.00
3   LINESTRING Z (32403693.547 5786613.994 -2400.0...   -2400.00
4   LINESTRING Z (32404738.664 5782672.480 -2350.0...   -2350.00