pyflwdir.FlwdirRaster.basins#

FlwdirRaster.basins(idxs: ndarray | None = None, xy: tuple[ndarray, ndarray] | None = None, ids: ndarray | None = None, **kwargs) → ndarray[source]#

Return a basin map with a unique ID for each basin.

Provide outlet indices or coordinates to delineate subbasins. Additional keyword arguments are passed to snap() to snap outlet locations to a downstream stream.

If ids is omitted, basin IDs start at 1. Zero is reserved for background and cannot be used as a basin ID.

Parameters:
  • idxs (array_like, optional) – Linear indices of basin outlets.

  • xy (tuple of array_like of float, optional) – x and y coordinates of basin outlets.

  • ids (1D array of uint32, optional) – Basin IDs in the same order as idxs, by default None.

  • **kwargs (dict) – Additional keyword arguments passed to snap() when outlet coordinates or indices are provided.

Returns:

Basin-ID raster, with zero as background.

Return type:

2D array of uint32