pyflwdir.FlwdirRaster.subgrid_rivavg#

FlwdirRaster.subgrid_rivavg(idxs_out: ndarray | None, data: ndarray, weights: ndarray | None = None, nodata: float = -9999.0, mask: ndarray | None = None, direction: Literal['up', 'down'] = 'up') → ndarray[source]#

Return the average value over the subgrid river at unit-catchment outlets.

The 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) – Linear indices of unit-catchment outlets. If None, use each raster cell as an outlet.

  • data (2D array) – Values to average.

  • weights (2D array, optional) – Weights used for averaging. Equal weights are used if omitted.

  • nodata (float, optional) – Missing data value for cells outside domain, by default -9999.0

  • mask (2D array of bool with self.shape, optional) – True for valid pixels. Can be used to exclude pixels outside the river.

  • direction ({"up", "down"}) – Flow direction in which the segment is defined, by default ‘up’.

Returns:

rivavg – Average value for each subgrid river segment.

Return type:

2D array of float with idxs_out.shape