API Reference
Datasets
download_dem(gdf, resolution, crs='EPSG:4326')
Source code in streamkit/datasets/usgs_downloader.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
download_flowlines(gdf, layer='medium', linestring_only=True, crs='EPSG:4326')
Source code in streamkit/datasets/usgs_downloader.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
get_huc_data(hucid, nhd_layer='medium', crs='EPSG:4326', dem_resolution=10)
Download hydrological and topographic data for a given HUC ID.
Retrieves NHD flowlines, and digital elevation model (DEM) data for the specified Hydrologic Unit Code (HUC) area.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in streamkit/datasets/usgs_downloader.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
load_sample_data()
Source code in streamkit/datasets/sample_data.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
Network Extraction
heads_from_flow_accumulation(flow_acc, flow_dir, threshold_area)
Source code in streamkit/extraction/heads.py
10 11 12 13 14 15 16 17 18 19 20 21 22 | |
heads_from_features(flowline_features, template_raster)
Source code in streamkit/extraction/heads.py
25 26 27 | |
extract_channel_network(channel_heads, flow_dir)
Source code in streamkit/extraction/network.py
9 10 11 12 | |
find_stream_nodes(stream_raster, flow_directions)
Identify source points and confluence points in a stream network Args: stream_raster: Raster representing the stream network (non-zero values indicate streams) flow_directions: Raster representing flow directions using ESRI convention Returns: Tuple containing lists of source points, confluence points, and outlet points
Source code in streamkit/extraction/nodes.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
delineate_subbasins(stream_raster, flow_directions, flow_accumulation)
Delineate all subbasins given a channel network raster. Detects pour points for each unique stream segment by finding the cell with the highest flow accumulation for that segment (based on ID).
| Parameters: |
|
|---|
Returns: Raster of subbasins with same IDs as stream_raster
Source code in streamkit/extraction/subbasins.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
delineate_reaches(stream_raster, dem, flow_dir, flow_acc, penalty=None, min_length=500, smooth_window=None, threshold_degrees=1.0)
Segment stream networks into reaches based on slope change points.
Uses the PELT (Pruned Exact Linear Time) changepoint detection algorithm to identify distinct reaches along each stream based on slope variations. Adjacent reaches with similar slopes can be merged using the threshold parameter.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in streamkit/extraction/reaches.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
Network Analysis
vectorize_streams(stream_raster, flow_directions, flow_accumulation)
Vectorize streams from a raster to a GeoDataFrame of LineStrings. Args: stream_raster: A raster of stream segments with unique IDs. flow_directions: A raster of flow directions (ESRI D8 encoding). flow_accumulation: A raster of flow accumulation values. Returns: A GeoDataFrame with LineString geometries representing the streams with stream_id column (from the raster values).
Source code in streamkit/network/stream_to_vector.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
analyze_stream_network(stream_network, dem, flow_direction, flow_accumulation)
Source code in streamkit/network/analysis.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
vector_to_graph(lines)
Source code in streamkit/network/graph_conversions.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
graph_to_vector(G)
Source code in streamkit/network/graph_conversions.py
27 28 29 30 31 32 33 34 35 36 37 38 39 | |
sample_cross_sections(xs_linestrings, point_interval)
Generate profile points along cross-section linestrings at regular intervals.
Creates evenly-spaced points along each cross-section line, measuring distances from the center point. Points are labeled as 'center', 'positive' (downstream of center), or 'negative' (upstream of center).
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in streamkit/network/cross_sections.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
network_cross_sections(linestrings, interval_distance, width, linestring_ids=None, smoothed=False)
Create cross-sections at regular intervals along linestrings.
| Parameters: |
|
|---|
Returns: cross section linestrings
Source code in streamkit/network/cross_sections.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
Terrain Analysis
condition_dem(dem, max_retries=3, wait_time=1.0)
Condition DEM using WhiteboxTools fill_depressions with retry logic.
Source code in streamkit/terrain/accumulation.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
flow_accumulation_workflow(dem)
Given a DEM, compute the conditioned DEM, flow directions, and flow accumulation. Uses d8 flow directions, wraps around whiteboxtools 'fill depression with fix flats' algorithm. Flow direction and accumulation done with pysheds. Uses ESRI flow direction encoding.
| Parameters: |
|
|---|
Returns: (conditioned DEM, flow directions, and flow accumulation)
Source code in streamkit/terrain/accumulation.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
create_cost_graph(dem, walls=None, enforce_uphill=False, enforce_downhill=False)
Source code in streamkit/terrain/cost.py
6 7 8 9 10 11 12 13 14 15 | |
compute_hand(dem, flow_directions, streams)
Source code in streamkit/terrain/elevation.py
40 41 42 43 44 45 46 47 48 49 | |
compute_hand_wbt(conditioned_dem, streams)
Source code in streamkit/terrain/elevation.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
compute_rem(dem, stream_mask, k=5, fit_regression=False, dist_method='cost-distance')
Source code in streamkit/terrain/elevation.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
subbasin_rem(dem, channel_network, subbasins, k=5, fit_regression=False, dist_method='cost-distance')
Source code in streamkit/terrain/elevation.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
gaussian_smooth_raster(raster, spatial_radius, sigma)
Apply Gaussian smoothing to a raster while preserving NaN values.
Performs NaN-aware Gaussian filtering that conserves intensity by only redistributing values between non-NaN pixels. NaN pixels remain NaN in the output.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in streamkit/terrain/smoothing.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
compute_distance_to_head(streams, flow_direction)
For each cell in the stream raster, compute the maximum upstream length (distance to furthest headwater)
| Parameters: |
|
|---|
Returns: A raster where each stream cell contains the maximum upstream length in map units.
Source code in streamkit/terrain/distance_to_head.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |