xrspatial.hydro.flow_length_dinf.flow_length_dinf#

xrspatial.hydro.flow_length_dinf.flow_length_dinf(flow_dir: DataArray, direction: str = 'downstream', name: str = 'flow_length_dinf') DataArray[source]#

Compute flow length from a D-infinity flow direction grid.

Parameters:
  • flow_dir (xarray.DataArray or xr.Dataset) – 2-D D-infinity flow direction grid as returned by flow_direction_dinf. Values are angles in radians [0, 2*pi), -1.0 for pits/flats, NaN for nodata. Supported backends: NumPy, CuPy, NumPy-backed Dask, CuPy-backed Dask. If a Dataset is passed, the operation is applied to each data variable independently.

  • direction (str, default 'downstream') – 'downstream': proportion-weighted average distance from each cell to its outlet. Flow is split between two neighbors following Tarboton (1997) angle decomposition. 'upstream': longest path from any divide to each cell.

  • name (str, default 'flow_length_dinf') – Name of output DataArray.

Returns:

2-D float64 array of flow length values in coordinate units. NaN where flow_dir is NaN.

Return type:

xarray.DataArray or xr.Dataset

References

Tarboton, D.G. (1997). A new method for the determination of flow directions and upslope areas in grid digital elevation models. Water Resources Research, 33(2), 309-319.