@@ -1477,60 +1477,76 @@ def extract_xyz_rasterio(
1477
1477
remove_total_bounds : bool = False ,
1478
1478
threshold_bounds : Union [float , int ] = 0.1 ,
1479
1479
) -> gpd .geodataframe .GeoDataFrame :
1480
- """Extracting X and Y coordinates from a GeoDataFrame (Points, LineStrings, MultiLineStrings Polygons) and z values
1481
- from a rasterio object and returning a GeoDataFrame with X, Y, and Z coordinates as additional columns
1480
+ """Extract X and Y coordinates from a GeoDataFrame (Points, LineStrings, MultiLineStrings Polygons) and z values
1481
+ from a rasterio object and returning a GeoDataFrame with X, Y, and Z coordinates as additional columns.
1482
1482
1483
1483
Parameters
1484
1484
__________
1485
1485
1486
1486
gdf : gpd.geodataframe.GeoDataFrame
1487
- GeoDataFrame created from vector data containing Shapely Points, LineStrings, MultiLineStrings or Polygons
1487
+ GeoDataFrame created from vector data containing Shapely Points, LineStrings, MultiLineStrings or Polygons.
1488
+
1489
+ +----+-----------+------------------------+
1490
+ | | formation | geometry |
1491
+ +----+-----------+------------------------+
1492
+ | 0 | Ton | POINT (19.150 293.313) |
1493
+ +----+-----------+------------------------+
1494
+ | 1 | Ton | POINT (61.934 381.459) |
1495
+ +----+-----------+------------------------+
1496
+ | 2 | Ton | POINT (109.358 480.946)|
1497
+ +----+-----------+------------------------+
1498
+ | 3 | Ton | POINT (157.812 615.999)|
1499
+ +----+-----------+------------------------+
1500
+ | 4 | Ton | POINT (191.318 719.094)|
1501
+ +----+-----------+------------------------+
1488
1502
1489
1503
dem : rasterio.io.DatasetReader
1490
- Rasterio object containing the height values
1504
+ Rasterio object containing the height values.
1491
1505
1492
- minz : float
1493
- Value defining the minimum elevation the data needs to be returned, e.g. ``minz=50``, default ``None``
1506
+ minz : float, default: ``None``
1507
+ Value defining the minimum elevation the data needs to be returned, e.g. ``minz=50``, default ``None``.
1494
1508
1495
- maxz : float
1496
- Value defining the maximum elevation the data needs to be returned, e.g. ``maxz=500``, default ``None``
1509
+ maxz : float, default: ``None``
1510
+ Value defining the maximum elevation the data needs to be returned, e.g. ``maxz=500``, default ``None```.
1497
1511
1498
- reset_index : bool
1499
- Variable to reset the index of the resulting GeoDataFrame, default ``True``
1512
+ reset_index : bool, default: ``True``
1513
+ Variable to reset the index of the resulting GeoDataFrame, e.g. ``reset_index=True``.
1514
+ Options include: ``True`` or ``False``, default set to ``True``.
1500
1515
1501
- drop_level0 : bool
1502
- Variable to drop the level_0 column.
1503
- Options include: ``True`` or ``False``, default set to ``True``
1516
+ drop_level0 : bool, default: ``True``
1517
+ Variable to drop the level_0 column, e.g. ``drop_level0=True`` .
1518
+ Options include: ``True`` or ``False``, default set to ``True``.
1504
1519
1505
- drop_level1 : bool
1506
- Variable to drop the level_1 column.
1507
- Options include: ``True`` or ``False``, default set to ``True``
1520
+ drop_level1 : bool, default: ``True``
1521
+ Variable to drop the level_1 column, e.g. ``drop_level1=True`` .
1522
+ Options include: ``True`` or ``False``, default set to ``True``.
1508
1523
1509
- drop_index : bool
1510
- Variable to drop the index column.
1511
- Options include: ``True`` or ``False``, default set to ``True``
1524
+ drop_index : bool, default: ``True``
1525
+ Variable to drop the index column, e.g. ``drop_index=True`` .
1526
+ Options include: ``True`` or ``False``, default set to ``True``.
1512
1527
1513
- drop_id : bool
1528
+ drop_id : bool, default: ``True``
1514
1529
Variable to drop the id column.
1515
- Options include: ``True`` or ``False``, default set to ``True``
1530
+ Options include: ``True`` or ``False``, default set to ``True``.
1516
1531
1517
- drop_points : bool
1518
- Variable to drop the points column.
1519
- Options include: ``True`` or ``False``, default set to ``True``
1532
+ drop_points : bool, default: ``True``
1533
+ Variable to drop the points column, e.g. ``drop_points=True`` .
1534
+ Options include: ``True`` or ``False``, default set to ``True``.
1520
1535
1521
- target_crs : Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS]
1522
- Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g. ``target_crs='EPSG:4647'``
1536
+ target_crs : Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS], default: ``None``
1537
+ Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g. ``target_crs='EPSG:4647'``.
1523
1538
1524
- bbox : list
1525
- Values (minx, maxx, miny, maxy) to limit the extent of the data, e.g. ``bbox=[0, 972, 0, 1069]``
1539
+ bbox : list, default: ``None``
1540
+ Values (minx, maxx, miny, maxy) to limit the extent of the data, e.g. ``bbox=[0, 972, 0, 1069]``.
1526
1541
1527
- remove_total_bounds: bool
1528
- Variable to remove the vertices representing the total bounds of a GeoDataFrame consisting of Polygons
1529
- Options include: ``True`` or ``False``, default set to ``False``
1542
+ remove_total_bounds: bool, default: ``False``
1543
+ Variable to remove the vertices representing the total bounds of a GeoDataFrame consisting of Polygons,
1544
+ e.g. ``remove_total_bounds=False``.
1545
+ Options include: ``True`` or ``False``, default set to ``False``.
1530
1546
1531
- threshold_bounds : Union[float, int]
1532
- Variable to set the distance to the total bound from where vertices are being removed,
1533
- e.g. ``threshold_bounds=10``, default set to ``0.1``
1547
+ threshold_bounds : Union[float, int], default: ``0.1``
1548
+ Variable to set the distance to the total bounds from where vertices are being removed,
1549
+ e.g. ``threshold_bounds=10``, default set to ``0.1``.
1534
1550
1535
1551
Returns
1536
1552
_______
@@ -1549,12 +1565,21 @@ def extract_xyz_rasterio(
1549
1565
>>> import rasterio
1550
1566
>>> gdf = gpd.read_file(filename='file.shp')
1551
1567
>>> gdf
1552
- id formation geometry
1553
- 0 None Ton POINT (19.150 293.313)
1554
- 1 None Ton POINT (61.934 381.459)
1555
- 2 None Ton POINT (109.358 480.946)
1556
- 3 None Ton POINT (157.812 615.999)
1557
- 4 None Ton POINT (191.318 719.094)
1568
+
1569
+ +----+-----------+------------------------+
1570
+ | | formation | geometry |
1571
+ +----+-----------+------------------------+
1572
+ | 0 | Ton | POINT (19.150 293.313) |
1573
+ +----+-----------+------------------------+
1574
+ | 1 | Ton | POINT (61.934 381.459) |
1575
+ +----+-----------+------------------------+
1576
+ | 2 | Ton | POINT (109.358 480.946)|
1577
+ +----+-----------+------------------------+
1578
+ | 3 | Ton | POINT (157.812 615.999)|
1579
+ +----+-----------+------------------------+
1580
+ | 4 | Ton | POINT (191.318 719.094)|
1581
+ +----+-----------+------------------------+
1582
+
1558
1583
1559
1584
>>> # Loading raster file
1560
1585
>>> dem = rasterio.open(fp='dem.tif')
@@ -1564,21 +1589,29 @@ def extract_xyz_rasterio(
1564
1589
>>> # Extracting X, Y, and Z Coordinates from Shapely Base Geometries and raster
1565
1590
>>> gdf_xyz = gg.vector.extract_xyz_rasterio(gdf=gdf, dem=dem, reset_index=reset_index)
1566
1591
>>> gdf_xyz
1567
- formation geometry X Y Z
1568
- 0 Ton POINT (19.150 293.313) 19.15 293.31 364.99
1569
- 1 Ton POINT (61.934 381.459) 61.93 381.46 400.34
1570
- 2 Ton POINT (109.358 480.946) 109.36 480.95 459.55
1571
- 3 Ton POINT (157.812 615.999) 157.81 616.00 525.69
1572
- 4 Ton POINT (191.318 719.094) 191.32 719.09 597.63
1592
+
1593
+ +----+-----------+------------------------+-------+-------+-------+
1594
+ | ID | formation | geometry | X | Y | Z |
1595
+ +----+-----------+------------------------+-------+-------+-------+
1596
+ | 0 | Ton | POINT (19.150 293.313) | 19.15 | 293.31| 364.99|
1597
+ +----+-----------+------------------------+-------+-------+-------+
1598
+ | 1 | Ton | POINT (61.934 381.459) | 61.93 | 381.46| 400.34|
1599
+ +----+-----------+------------------------+-------+-------+-------+
1600
+ | 2 | Ton | POINT (109.358 480.946)| 109.36| 480.95| 459.55|
1601
+ +----+-----------+------------------------+-------+-------+-------+
1602
+ | 3 | Ton | POINT (157.812 615.999)| 157.81| 616.00| 525.69|
1603
+ +----+-----------+------------------------+-------+-------+-------+
1604
+ | 4 | Ton | POINT (191.318 719.094)| 191.32| 719.09| 597.63|
1605
+ +----+-----------+------------------------+-------+-------+-------+
1606
+
1573
1607
1574
1608
See Also
1575
1609
________
1576
1610
1577
- extract_xyz_array : Extracting X, Y, and Z coordinates from a GeoDataFrame and Digital Elevation Model as array
1578
- extract_xyz : Extracting X, Y, and Z coordinates from a GeoDataFrame and Digital Elevation Model
1611
+ extract_xyz : Extract X, Y, and Z coordinates from a GeoDataFrame and Digital Elevation Model
1612
+ extract_xyz_array : Extract X, Y, and Z coordinates from a GeoDataFrame and Digital Elevation Model as array
1579
1613
1580
1614
"""
1581
-
1582
1615
# Checking that the input data is of type GeoDataFrame
1583
1616
if not isinstance (gdf , gpd .geodataframe .GeoDataFrame ):
1584
1617
raise TypeError ("Loaded object is not a GeoDataFrame" )
@@ -1725,7 +1758,7 @@ def extract_xyz_rasterio(
1725
1758
1726
1759
# Extracting the X and Y coordinates of the reprojected gdf
1727
1760
gdf = extract_xy (
1728
- gdf ,
1761
+ gdf = gdf ,
1729
1762
reset_index = False ,
1730
1763
drop_index = False ,
1731
1764
drop_id = False ,
0 commit comments