API Reference
Watershed Analysis
            compute_hand(dem, flow_directions, streams)
    Source code in streamkit/watershed.py
              | 74 75 76 77 78 79 80 81 82 83 |  | 
            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/watershed.py
              | 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 |  | 
            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/watershed.py
              | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |  | 
Stream Vectorization and Network Conversion
            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/vectorize_streams.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 |  | 
            vector_streams_to_networkx(lines)
    Convert a GeoDataFrame of LineString geometries to a NetworkX directed graph.
Creates a directed graph where nodes represent stream endpoints (start and end coordinates) and edges represent stream segments. All attributes from the input GeoDataFrame are preserved as edge attributes in the graph.
| Parameters: | 
 | 
|---|
| Returns: | 
 | 
|---|
Source code in streamkit/nx_convert.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 |  | 
            networkx_to_gdf(G)
    Convert a NetworkX directed graph back to a GeoDataFrame.
Reconstructs vector stream data from a graph representation by converting each edge into a LineString geometry connecting its start and end nodes. All edge attributes are preserved in the output GeoDataFrame.
| Parameters: | 
 | 
|---|
| Returns: | 
 | 
|---|
Source code in streamkit/nx_convert.py
              | 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 |  | 
Network Analysis
            strahler_order(G)
    Calculate the Strahler order for each edge in a directed graph.
| Parameters: | 
 | 
|---|
Returns: The same directed graph with an additional 'strahler' attribute on each edge indicating its Strahler order.
Source code in streamkit/strahler.py
              | 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |  | 
            upstream_length(G)
    Compute the maximum upstream length for each edge in a directed graph G. Uses the length attribute of the edge geometry.
| Parameters: | 
 | 
|---|
Returns: A copy of the graph with an additional attribute 'max_upstream_length' for each edge.
Source code in streamkit/upstream_length.py
              | 66 67 68 69 70 71 72 73 74 75 76 77 78 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 105 106 107 108 109 110 |  | 
            label_mainstem(G)
    Label mainstem edges in a stream network graph.
Identifies and labels the main channel (mainstem) of each drainage network by traversing from outlet nodes upstream. Edges are labeled with a 'mainstem' attribute set to True for mainstem edges and False for tributaries.
| Parameters: | 
 | 
|---|
| Returns: | 
 | 
|---|
| Raises: | 
 | 
|---|
Source code in streamkit/mainstem.py
              | 4 5 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 33 34 35 36 37 38 39 40 41 42 |  | 
            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/xs.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 |  | 
            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/profile.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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |  | 
Terrain Analysis
            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/smooth.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 |  | 
            upstream_length_raster(streams, flow_direction)
    For each cell in the stream raster, compute the maximum upstream length
| Parameters: | 
 | 
|---|
Returns: A raster where each stream cell contains the maximum upstream length in map units.
Source code in streamkit/upstream_length.py
              | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |  | 
Reach Delineation
            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/reach.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 |  | 
Data Download Utilities
            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/data.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 |  | 
            download_huc_bounds(huc, wbd=None)
    Source code in streamkit/data.py
              | 50 51 52 53 54 55 56 57 58 |  | 
            download_flowlines(gdf, layer='medium', linestring_only=True, crs='EPSG:4326')
    Source code in streamkit/data.py
              | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |  | 
            download_dem(gdf, resolution, crs='EPSG:4326')
    Source code in streamkit/data.py
              | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |  | 
NHD Utilities
            rasterize_nhd(nhd_flowlines, flow_dir)
    Create a raster representation of NHD flowlines
Converts vector NHD flowlines to a raster stream network by identifying channel heads, tracing streams downslope along the flow direction raster, and linking stream segments. Small streams (< 2 pixels) are removed and the remaining streams are relabeled with consecutive integers.
| Parameters: | 
 | 
|---|
| Returns: | 
 | 
|---|
Source code in streamkit/nhd.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 56 57 |  |