xrspatial.flood.travel_time#

xrspatial.flood.travel_time(flow_length_agg: DataArray, slope_agg: DataArray, mannings_n: float | DataArray, name: str = 'travel_time') DataArray[source]#

Estimate overland flow travel time via simplified Manning’s equation.

Velocity is estimated as v = (1/n) * sqrt(tan(slope)) and travel time as flow_length / v. Near-zero slopes are clamped to tan(0.001 deg) (same as TWI) to avoid division by zero.

The time of concentration for a catchment is simply travel_time(...).max().

Parameters:
  • flow_length_agg (xarray.DataArray) – 2D flow length raster (output of flow_length()).

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

  • mannings_n (float or xarray.DataArray) – Manning’s roughness coefficient (> 0). A scalar applies uniformly; a DataArray allows spatially varying roughness.

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

Returns:

2D float64 travel time grid (same time units as flow_length distance units and velocity units, typically seconds when flow_length is in metres).

Return type:

xarray.DataArray

Notes

Supports NumPy, CuPy, Dask with NumPy, and Dask with CuPy backed xarray DataArrays. NaN in flow_length_agg or slope_agg propagates to NaN in the output.

Examples

>>> import numpy as np
>>> import xarray as xr
>>> from xrspatial import travel_time
>>> flow_length = xr.DataArray(
...     np.array([[100.0, 200.0]]), dims=['y', 'x'])
>>> slope = xr.DataArray(
...     np.array([[10.0, 45.0]]), dims=['y', 'x'])
>>> tt = travel_time(flow_length, slope, mannings_n=0.03)