In [1]:
Copied!
import geopandas as gpd
import rioxarray as rxr
import matplotlib.pyplot as plt
from streamkit import (
    network_cross_sections, sample_cross_sections)
import geopandas as gpd
import rioxarray as rxr
import matplotlib.pyplot as plt
from streamkit import (
    network_cross_sections, sample_cross_sections)
OMP: Info #276: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.
In [2]:
Copied!
streams = gpd.read_file("data/sample_streams_vec.gpkg")
dem = rxr.open_rasterio("data/sample_dem.tif", masked=True).squeeze()
streams = gpd.read_file("data/sample_streams_vec.gpkg")
dem = rxr.open_rasterio("data/sample_dem.tif", masked=True).squeeze()
In [10]:
Copied!
xsections = network_cross_sections(streams.geometry, 100, 1000, smoothed=True)
fig, ax = plt.subplots(figsize=(10,10))
dem.plot(ax=ax)
xsections.plot(ax=ax, color='red')
xsections = network_cross_sections(streams.geometry, 100, 1000, smoothed=True)
fig, ax = plt.subplots(figsize=(10,10))
dem.plot(ax=ax)
xsections.plot(ax=ax, color='red')
Out[10]:
<Axes: title={'center': 'band = 1, spatial_ref = 0'}, xlabel='x', ylabel='y'>
In [7]:
Copied!
elevation_profiles = sample_cross_sections(xsections, 10)
elevation_profiles
elevation_profiles = sample_cross_sections(xsections, 10)
elevation_profiles
Out[7]:
| side | geometry | distance | xs_id | linestring_id | |
|---|---|---|---|---|---|
| 0 | center | POINT (-333906.629 346117.375) | 0.0 | 1 | 0 | 
| 1 | positive | POINT (-333896.63 346117.224) | 10.0 | 1 | 0 | 
| 2 | positive | POINT (-333886.632 346117.072) | 20.0 | 1 | 0 | 
| 3 | positive | POINT (-333876.633 346116.92) | 30.0 | 1 | 0 | 
| 4 | positive | POINT (-333866.634 346116.768) | 40.0 | 1 | 0 | 
| ... | ... | ... | ... | ... | ... | 
| 81600 | negative | POINT (-337712.067 342108.105) | -450.0 | 816 | 37 | 
| 81601 | negative | POINT (-337704.981 342115.161) | -460.0 | 816 | 37 | 
| 81602 | negative | POINT (-337697.895 342122.217) | -470.0 | 816 | 37 | 
| 81603 | negative | POINT (-337690.809 342129.273) | -480.0 | 816 | 37 | 
| 81604 | negative | POINT (-337683.723 342136.329) | -490.0 | 816 | 37 | 
81605 rows × 5 columns