Add D-inf and MFD stream ordering and link segmentation#984
Merged
brendancol merged 2 commits intomasterfrom Mar 6, 2026
Merged
Add D-inf and MFD stream ordering and link segmentation#984brendancol merged 2 commits intomasterfrom
brendancol merged 2 commits intomasterfrom
Conversation
Four new public functions: - stream_order_dinf: Strahler/Shreve ordering on D-inf angle grids - stream_order_mfd: Strahler/Shreve ordering on MFD fraction grids - stream_link_dinf: link segmentation on D-inf angle grids - stream_link_mfd: link segmentation on MFD fraction grids All four support NumPy, CuPy, Dask+NumPy, and Dask+CuPy backends.
Upstream added a Source column to the feature matrix. Kept the upstream format and added the 4 new stream analysis rows with Source references.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #983.
Summary
stream_order_dinfandstream_link_dinffor D-infinity (Tarboton 1997) flow direction gridsstream_order_mfdandstream_link_mfdfor Multiple Flow Direction fraction gridsWhat changed
New modules (4):
xrspatial/stream_order_dinf.py-- D-inf angle -> two bracketing neighbors with fractional weights, then Kahn's BFS same as D8xrspatial/stream_order_mfd.py-- MFD (8, H, W) fraction grid -> all downslope neighbors, then Kahn's BFSxrspatial/stream_link_dinf.py-- link segmentation using D-inf topologyxrspatial/stream_link_mfd.py-- link segmentation using MFD topologyTests (4 files, 31 tests):
Docs and examples:
hydrology.rstupdated with 4 new API entriesREADME.mdfeature matrix updated25_Stream_Analysis_Dinf_MFD.ipynbDesign notes
The topology construction differs per routing model, but the BFS ordering and link segmentation logic is identical to the existing D8 implementations. D-inf decomposes each angle into two bracketing neighbors. MFD reads directly from the 8-band fraction array. Once the flow graph is built, Strahler/Shreve ordering and link ID assignment work the same way.
Test plan
pytest xrspatial/tests/test_stream_{order,link}_{dinf,mfd}.py)