Skip to content

Commit 187032a

Browse files
committed
Add D-infinity flow length computation (#1012)
New flow_length_dinf() computes flow path lengths from D-inf angle grids using Tarboton's two-neighbor angle decomposition. Downstream mode gives the proportion-weighted distance to outlet; upstream mode gives the longest path from any divide. All four backends: NumPy, CuPy, Dask+NumPy, Dask+CuPy. 25 tests covering correctness, edge cases, and cross-backend consistency. Also adds the missing flow_accumulation_dinf entry to the README feature matrix.
1 parent 0d1bdfb commit 187032a

File tree

5 files changed

+1256
-0
lines changed

5 files changed

+1256
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,10 @@ In the GIS world, rasters are used for representing continuous phenomena (e.g. e
293293
| [Flow Direction (Dinf)](xrspatial/flow_direction_dinf.py) | Computes D-infinity flow direction as a continuous angle toward the steepest downslope facet | Tarboton 1997 | ✅️ | ✅️ | ✅️ | ✅️ |
294294
| [Flow Direction (MFD)](xrspatial/flow_direction_mfd.py) | Partitions flow to all downslope neighbors with an adaptive exponent (Qin et al. 2007) | Qin et al. 2007 | ✅️ | ✅️ | ✅️ | ✅️ |
295295
| [Flow Accumulation (D8)](xrspatial/flow_accumulation.py) | Counts upstream cells draining through each cell in a D8 flow direction grid | Jenson & Domingue 1988 | ✅️ | ✅️ | ✅️ | ✅️ |
296+
| [Flow Accumulation (Dinf)](xrspatial/flow_accumulation_dinf.py) | Accumulates upstream area by splitting flow proportionally between two neighbors (Tarboton 1997) | Tarboton 1997 | ✅️ | ✅️ | ✅️ | 🔄 |
296297
| [Flow Accumulation (MFD)](xrspatial/flow_accumulation_mfd.py) | Accumulates upstream area through all MFD flow paths weighted by directional fractions | Qin et al. 2007 | ✅️ | ✅️ | ✅️ | 🔄 |
298+
| [Flow Length (D8)](xrspatial/flow_length.py) | Computes D8 flow path length from each cell to outlet (downstream) or from divide (upstream) | Standard (D8 tracing) | ✅️ | ✅️ | ✅️ | 🔄 |
299+
| [Flow Length (Dinf)](xrspatial/flow_length_dinf.py) | Proportion-weighted flow path length using D-inf angle decomposition (downstream or upstream) | Tarboton 1997 | ✅️ | ✅️ | ✅️ | 🔄 |
297300
| [Watershed](xrspatial/watershed.py) | Labels each cell with the pour point it drains to via D8 flow direction | Standard (D8 tracing) | ✅️ | ✅️ | ✅️ | ✅️ |
298301
| [Basins](xrspatial/watershed.py) | Delineates drainage basins by labeling each cell with its outlet ID | Standard (D8 tracing) | ✅️ | ✅️ | ✅️ | ✅️ |
299302
| [Stream Order](xrspatial/stream_order.py) | Assigns Strahler or Shreve stream order to cells in a drainage network | Strahler 1957, Shreve 1966 | ✅️ | ✅️ | ✅️ | ✅️ |

docs/source/reference/hydrology.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ Flow Length
5353

5454
xrspatial.flow_length.flow_length
5555

56+
Flow Length (D-infinity)
57+
========================
58+
.. autosummary::
59+
:toctree: _autosummary
60+
61+
xrspatial.flow_length_dinf.flow_length_dinf
62+
5663
Flow Path
5764
=========
5865
.. autosummary::

xrspatial/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
from xrspatial.flow_direction_dinf import flow_direction_dinf # noqa
4646
from xrspatial.flow_direction_mfd import flow_direction_mfd # noqa
4747
from xrspatial.flow_length import flow_length # noqa
48+
from xrspatial.flow_length_dinf import flow_length_dinf # noqa
4849
from xrspatial.flow_path import flow_path # noqa
4950
from xrspatial.focal import mean # noqa
5051
from xrspatial.glcm import glcm_texture # noqa

0 commit comments

Comments
 (0)