pyflwdir.FlwdirRaster.subgrid_rivlen#

FlwdirRaster.subgrid_rivlen(idxs_out: ndarray | None, mask: ndarray | None = None, direction: Literal['up', 'down'] = 'up', unit: Literal['m', 'cell'] = 'cell') → ndarray[source]#

Returns the subgrid river length [m] based on unit catchment outlet locations. A cell’s subgrid river is defined by the path starting at the unit catchment outlet pixel moving up- or downstream until it reaches the next outlet pixel. If moving upstream and a pixel has multiple upstream neighbors, the pixel with the largest upstream area is selected.

Parameters:
  • idxs_out (2D array of int, optional) – Linear indices of unit catchment outlets. If None, the cell size (instead of subgrid length) will be used.

  • mask (2D array of bool with self.shape, optional) – True for valid pixels. can be used to mask out pixels of small rivers.

  • direction ({"up", "down"}) – Flow direction in which river length is measured, by default ‘up’.

  • unit ({'m', 'cell'}, optional) – River-length unit, either metres (‘m’) or cells (‘cell’), by default ‘cell’.

Returns:

rivlen – subgrid river length [m]

Return type:

2D array of float with idxs_out.shape