xrspatial.hydro.flow_accumulation_d8.flow_accumulation_d8#
- xrspatial.hydro.flow_accumulation_d8.flow_accumulation_d8(flow_dir: DataArray, name: str = 'flow_accumulation') DataArray[source]#
Compute flow accumulation from a D8 flow direction grid.
Each cell drains to exactly one downstream neighbor based on integer D8 direction codes. For D-infinity (continuous angle) grids, use
flow_accumulation_dinfinstead.- Parameters:
flow_dir (xarray.DataArray or xr.Dataset) – 2D flow direction grid with D8 codes: 0/1/2/4/8/16/32/64/128 (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.
name (str, default='flow_accumulation') – Name of output DataArray.
- Returns:
2D float64 array of flow accumulation values. Each cell contains the count of upstream cells (including itself) that drain through it. Cells with NaN flow direction produce NaN.
- Return type:
xarray.DataArray or xr.Dataset
References
Jenson, S.K. and Domingue, J.O. (1988). Extracting Topographic Structure from Digital Elevation Data for Geographic Information System Analysis. Photogrammetric Engineering and Remote Sensing, 54(11), 1593-1600.