pyflwdir.FlwdirRaster.streams#

FlwdirRaster.streams(mask: ndarray | None = None, min_sto: int = 1, xs: ndarray | None = None, ys: ndarray | None = None, idxs_out: ndarray | None = None, max_len: int = 0, direction: Literal['up', 'down'] = 'up', **kwargs) → list[dict][source]#

Return stream segments as LineString geographic features.

A segment follows a flow path between confluences, or between outlet cells supplied through idxs_out. Stream cells are selected with either mask or min_sto; when mask is provided, min_sto is ignored.

Additional keyword arguments provide maps sampled at the most downstream cell of each stream segment.

Parameters:
  • mask (2D array of bool) – Mask selecting stream cells. If provided, min_sto is ignored.

  • min_sto (int) – Minimum Strahler order recognized as a stream, by default 1. An existing stream-order map can be passed through the strord keyword argument.

  • xs (2D array of float) – Rasters of cell-center x and y coordinates. Inferred from the affine transform if omitted.

  • ys (2D array of float) – Rasters of cell-center x and y coordinates. Inferred from the affine transform if omitted.

  • idxs_out (1D array of int, optional) – Linear indices of segment-end cells. Segments follow the path between successive end cells in the direction specified by direction. By default, segments are defined by confluences.

  • direction ({'up', 'down'}, optional) – Flow direction between segment-end cells. Used only when idxs_out is provided, by default ‘up’.

  • max_len (int, optional) – Maximum length of a single stream segment measured in cells. Longer segments are divided into shorter segments with lengths as close as possible to max_len, by default 0 (no maximum length).

  • **kwargs (2D array-like) – Additional maps sampled at each segment’s most downstream cell and included as feature properties.

Returns:

feats – LineString features, suitable for geopandas.GeoDataFrame.from_features.

Return type:

list of dict