xrspatial.hydro.stream_order_d8.stream_order_d8#

xrspatial.hydro.stream_order_d8.stream_order_d8(flow_dir: DataArray, flow_accum: DataArray, threshold: float = 100, ordering: str = 'strahler', name: str = 'stream_order', method: str | None = None) DataArray[source]#

Compute stream order from D8 flow direction and accumulation grids.

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).

  • flow_accum (xarray.DataArray) – 2D flow accumulation grid. Cells with flow_accum >= threshold are considered stream cells.

  • threshold (float, default 100) – Minimum accumulation to classify a cell as part of the stream network.

  • ordering (str, default 'strahler') – 'strahler' for Strahler branching hierarchy or 'shreve' for Shreve cumulative magnitude.

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

  • method (str, optional) – Alias for ordering, accepted for consistency with stream_order_dinf and stream_order_mfd, which name this parameter method. If given, it takes precedence over ordering. Passing both with conflicting values raises ValueError.

Returns:

2D float64 array of stream order values. Non-stream cells (accumulation below threshold) are NaN.

Return type:

xarray.DataArray or xr.Dataset

References

Strahler, A.N. (1957). Quantitative analysis of watershed geomorphology. Transactions of the American Geophysical Union, 38(6), 913-920.

Shreve, R.L. (1966). Statistical law of stream numbers. Journal of Geology, 74(1), 17-37.