hydromt.flw.basin_map#

hydromt.flw.basin_map(ds: Dataset, flwdir: FlwdirRaster, xy: Tuple | None = None, idxs: ndarray | None = None, outlets: bool = False, ids: ndarray | None = None, stream: DataArray | None = None, **stream_kwargs) DataArray | Tuple[source]#

Return a (sub)basin map, with unique non-zero IDs for each subbasin.

Parameters:
  • ds (xarray.Dataset) – Dataset used for output grid definition and containing stream_kwargs variables.

  • flwdir (pyflwdir.FlwdirRaster) – Flow direction raster object

  • idxs (1D array or int, optional) – linear indices of sub(basin) outlets, by default is None.

  • xy (tuple of 1D array of float, optional) – x, y coordinates of sub(basin) outlets, by default is None.

  • outlets (bool, optional) – If True and xy and idxs are None, the basin map is derived for basin outlets only, excluding pits at the edge of the domain of incomplete basins.

  • ids (1D array of int32, optional) – IDs of (sub)basins, must be larger than zero, by default None

  • stream (2D array of bool, optional) – Mask of stream cells used to snap outlets to, by default None

  • stream_kwargs (dict, optional) – Parameter-treshold pairs to define streams. Multiple threshold will be combined using a logical_and operation. If a stream if provided, it is combined with the threshhold based map as well.

Returns:

  • da_basin (xarray.DataArray of int32) – basin ID map

  • xy (tuple of array_like of float) – snapped x, y coordinates of sub(basin) outlets