pyflwdir.FlwdirRaster.path#
- FlwdirRaster.path(idxs: ndarray | None = None, xy: tuple[ndarray, ndarray] | None = None, mask: ndarray | None = None, max_length: float | None = None, unit: Literal['m', 'cell'] = 'cell', direction: Literal['up', 'down'] = 'down') tuple[list[ndarray], ndarray][source]#
Trace paths downstream or upstream from starting cells.
A path ends at a pit, at a True cell in mask, or when max_length is exceeded. The endpoint is included in the returned path. Provide either idxs or xy to specify starting cells.
- Parameters:
idxs (array_like, optional) – Linear indices of starting cells.
xy (tuple of array_like of float, optional) – x and y coordinates of starting cells.
mask (2D array of bool, optional) – True for cells where tracing stops; the matching cell is included.
max_length (float, optional) – Maximum path length, measured in unit.
unit ({'m', 'cell'}, optional) – Length unit, either metres (‘m’) or cells (‘cell’), by default ‘cell’.
direction ({'up', 'down'}, optional) – Trace downstream (‘down’, default) or upstream (‘up’).
- Returns:
list of 1D-array of int – List of arrays containing the linear indices in each path.
1D array of float – Distance from each start cell to its path endpoint, in unit.