xrspatial.hydro.flow_length_d8.flow_length_d8#

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

Compute D8 flow length from a flow direction grid.

Parameters:
  • flow_dir (xarray.DataArray or xr.Dataset) – 2D D8 flow direction grid (codes 0/1/2/4/8/16/32/64/128; NaN for nodata).

  • direction (str, default 'downstream') – 'downstream': distance from each cell to its outlet. 'upstream': longest path from any divide to each cell.

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

Returns:

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

Return type:

xarray.DataArray or xr.Dataset