@@ -3686,29 +3686,51 @@ def create_linestrings_from_contours(
3686
3686
return_gdf : bool = True ,
3687
3687
crs : Union [str , pyproj .crs .crs .CRS ] = None ,
3688
3688
) -> 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.
3690
3690
3691
3691
Parameters
3692
3692
__________
3693
3693
3694
3694
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
+ +--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3696
3716
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``.
3700
3720
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'``.
3703
3723
3704
3724
Returns
3705
3725
_______
3706
3726
3707
3727
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.
3709
3729
3710
3730
.. versionadded:: 1.0.x
3711
3731
3732
+ .. versionchanged:: 1.2
3733
+
3712
3734
Example
3713
3735
_______
3714
3736
@@ -3717,30 +3739,45 @@ def create_linestrings_from_contours(
3717
3739
>>> import pyvista as pv
3718
3740
>>> contours = pv.read('file.vtk')
3719
3741
>>> 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
+ +--------------+-----------------------+-------------+---------+---------+--------+------------+-----------+
3731
3761
3732
3762
>>> # Extracting LineStrings from contours
3733
3763
>>> gdf = gg.vector.create_linestrings_from_contours(contours=contours)
3734
3764
>>> 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
+ +----+----------------------------------------------------+---------+
3741
3778
3742
- """
3743
3779
3780
+ """
3744
3781
# Checking that the input data is a PyVista PolyData dataset
3745
3782
if not isinstance (contours , pv .core .pointset .PolyData ):
3746
3783
raise TypeError ("Input data must be a PyVista PolyData dataset" )
0 commit comments