pyflwdir.from_array#

pyflwdir.from_array(data: ndarray, ftype: Literal['d8', 'ldd', 'nextxy', 'infer'] = 'infer', check_ftype: bool = True, mask: ndarray | None = None, transform: Affine = Affine(1.0, 0.0, 0.0, 0.0, -1.0, 0.0), latlon: bool = False, **kwargs) → FlwdirRaster[source]#

Parse a flow-direction raster into the actionable FlwDirRaster format.

Parameters:
  • data (2D array) – 2D flow-direction raster. For ftype=’nextxy’, provide the pair of row and column arrays.

  • ftype ({'d8', 'ldd', 'nextxy', 'infer'}, optional) – Flow-direction convention. Use ‘infer’ to detect it from data, by default ‘infer’.

  • check_ftype (bool, optional) – Whether to validate data against ftype, by default True. Validation is skipped when ftype=’infer’ because inference performs the check.

  • mask (2D array of bool, optional) – True for valid cells. Can be used to exclude cells outside the domain.

  • transform (affine transform) – Affine transform mapping pixel coordinates to map coordinates, by default the identity transform.

  • latlon (bool, optional) – Whether coordinates use the WGS84 geographic coordinate system. If True, cell areas are converted from degrees to square metres; otherwise coordinates are assumed to use metres, by default False.

  • **kwargs (dict) – Additional keyword arguments passed to the FlwDirRaster constructor, such as cache.

Returns:

Parsed flow-direction raster.

Return type:

FlwdirRaster