xrspatial.hydro.twi_d8.twi_d8#

xrspatial.hydro.twi_d8.twi_d8(flow_accum: DataArray, slope_agg: DataArray, name: str = 'twi') DataArray[source]#

Compute the Topographic Wetness Index.

TWI = ln(a / tan(β)), where a = flow_accum × cellsize (specific catchment area) and β = slope in radians. Slope input is expected in degrees (matching the output of slope()).

Parameters:
  • flow_accum (xarray.DataArray) – 2D flow accumulation grid (cell counts).

  • slope_agg (xarray.DataArray) – 2D slope grid in degrees.

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

Returns:

2D float64 TWI grid. NaN where either input is NaN.

Return type:

xarray.DataArray