Skip to content

Commit 021a2b1

Browse files
Format create_linestrings_from_contours
1 parent 53cbfbe commit 021a2b1

File tree

1 file changed

+63
-26
lines changed

1 file changed

+63
-26
lines changed

gemgis/vector.py

Lines changed: 63 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3686,29 +3686,51 @@ def create_linestrings_from_contours(
36863686
return_gdf: bool = True,
36873687
crs: Union[str, pyproj.crs.crs.CRS] = None,
36883688
) -> Union[List[shapely.geometry.linestring.LineString], gpd.geodataframe.GeoDataFrame]:
3689-
"""Creating LineStrings from PyVista Contour Lines and save them as list or GeoDataFrame
3689+
"""Create LineStrings from PyVista Contour Lines and save them as list or GeoDataFrame.
36903690
36913691
Parameters
36923692
__________
36933693
36943694
contours : pv.core.pointset.PolyData
3695-
PyVista PolyData dataset containing contour lines extracted from a mesh
3695+
PyVista PolyData dataset containing contour lines extracted from a mesh.
3696+
3697+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3698+
| Header | | Data Array | | | | | |
3699+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3700+
| PolyData | Information | Name | Field | Type | N Comp | Min | Max |
3701+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3702+
| N Cells | 580 | Depth [m] | Points | float64 | 1 | -1.710e+03 | 3.000e+02 |
3703+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3704+
| N Points | 586 | | | | | | |
3705+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3706+
| N Strips | 0 | | | | | | |
3707+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3708+
| X Bounds | 2.952e+05, 3.016e+05 | | | | | | |
3709+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3710+
| Y Bounds | 5.619e+06, 5.627e+06 | | | | | | |
3711+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3712+
| Z Bounds | -1.710e+03, 3.000e+02 | | | | | | |
3713+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3714+
| N Arrays | 1 | | | | | | |
3715+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
36963716
3697-
return_gdf : bool
3698-
Variable to create GeoDataFrame of the created list of Shapely Objects.
3699-
Options include: ``True`` or ``False``, default set to ``True``
3717+
return_gdf : bool, default: ``True``
3718+
Variable to create GeoDataFrame of the created list of Shapely Objects, e.g. ``return_gdf=True``.
3719+
Options include: ``True`` or ``False``, default set to ``True``.
37003720
3701-
crs : Union[str, pyproj.crs.crs.CRS]
3702-
Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g. ``crs='EPSG:4647'``
3721+
crs : Union[str, pyproj.crs.crs.CRS], default: ``None``
3722+
Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g. ``crs='EPSG:4647'``.
37033723
37043724
Returns
37053725
_______
37063726
37073727
linestrings : Union[List[shapely.geometry.linestring.LineString], gpd.geodataframe.GeoDataFrame]
3708-
List of LineStrings or GeoDataFrame containing the contours that were converted
3728+
List of LineStrings or GeoDataFrame containing the contours that were converted.
37093729
37103730
.. versionadded:: 1.0.x
37113731
3732+
.. versionchanged:: 1.2
3733+
37123734
Example
37133735
_______
37143736
@@ -3717,30 +3739,45 @@ def create_linestrings_from_contours(
37173739
>>> import pyvista as pv
37183740
>>> contours = pv.read('file.vtk')
37193741
>>> contours
3720-
Header
3721-
PolyData Information
3722-
N Cells 36337
3723-
N Points 36178
3724-
X Bounds 3.233e+07, 3.250e+07
3725-
Y Bounds 5.704e+06, 5.798e+06
3726-
Z Bounds -2.400e+03, 3.500e+02
3727-
N Arrays 1
3728-
Data Arrays
3729-
Name Field Type N Comp Min Max
3730-
Depth [m] Points float64 1 -2.400e+03 3.500e+02
3742+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3743+
| Header | | Data Array | | | | | |
3744+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3745+
| PolyData | Information | Name | Field | Type | N Comp | Min | Max |
3746+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3747+
| N Cells | 580 | Depth [m] | Points | float64 | 1 | -1.710e+03 | 3.000e+02 |
3748+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3749+
| N Points | 586 | | | | | | |
3750+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3751+
| N Strips | 0 | | | | | | |
3752+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3753+
| X Bounds | 2.952e+05, 3.016e+05 | | | | | | |
3754+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3755+
| Y Bounds | 5.619e+06, 5.627e+06 | | | | | | |
3756+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3757+
| Z Bounds | -1.710e+03, 3.000e+02 | | | | | | |
3758+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3759+
| N Arrays | 1 | | | | | | |
3760+
+--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
37313761
37323762
>>> # Extracting LineStrings from contours
37333763
>>> gdf = gg.vector.create_linestrings_from_contours(contours=contours)
37343764
>>> gdf
3735-
geometry Z
3736-
0 LINESTRING Z (32409587.930 5780538.824 -2350.0... -2350.00
3737-
1 LINESTRING Z (32407304.336 5777048.086 -2050.0... -2050.00
3738-
2 LINESTRING Z (32408748.977 5778005.047 -2200.0... -2200.00
3739-
3 LINESTRING Z (32403693.547 5786613.994 -2400.0... -2400.00
3740-
4 LINESTRING Z (32404738.664 5782672.480 -2350.0... -2350.00
3765+
+----+----------------------------------------------------+---------+
3766+
| | geometry | Z |
3767+
+----+----------------------------------------------------+---------+
3768+
| 0 | LINESTRING Z (32409587.930 5780538.824 -2350.0...) | -2350.00|
3769+
+----+----------------------------------------------------+---------+
3770+
| 1 | LINESTRING Z (32407304.336 5777048.086 -2050.0...) | -2050.00|
3771+
+----+----------------------------------------------------+---------+
3772+
| 2 | LINESTRING Z (32408748.977 5778005.047 -2200.0...) | -2200.00|
3773+
+----+----------------------------------------------------+---------+
3774+
| 3 | LINESTRING Z (32403693.547 5786613.994 -2400.0...) | -2400.00|
3775+
+----+----------------------------------------------------+---------+
3776+
| 4 | LINESTRING Z (32404738.664 5782672.480 -2350.0...) | -2350.00|
3777+
+----+----------------------------------------------------+---------+
37413778
3742-
"""
37433779
3780+
"""
37443781
# Checking that the input data is a PyVista PolyData dataset
37453782
if not isinstance(contours, pv.core.pointset.PolyData):
37463783
raise TypeError("Input data must be a PyVista PolyData dataset")

0 commit comments

Comments
 (0)