pyflwdir.regions.region_dissolve#

pyflwdir.regions.region_dissolve(regions, labels=None, idxs=None, transform=Affine(1.0, 0.0, 0.0, 0.0, -1.0, 0.0), latlon=False, **kwargs)[source]#

Dissolve regions into its nearest neighboring regions.

Regions to be dissolved are provided by either their labels or one location per region expressed with a linear index in idxs. These regions are assigned the label of the nearest neighboring region. If a locations idxs are provided the proximitity to other regions from that location. This can be usefull to e.g. dissolve basins based on the distance from its outlet.

Parameters:
  • regions (2D-array of int) – raster with unique non-zero positive IDs for each region

  • labels (1D-array of int) – labels of regions to be dissolved. Must be unique and larger than zero.

  • idxs (1D-array of int) – linear index of one location per region to be dissolved

  • latlon (bool) – True for geographic CRS, False for projected CRS. If True, the transform units are assumed to be degrees and converted to metric distances.

  • transform (Affine) – Coefficients mapping pixel coordinates to coordinate reference system.

Returns:

basins_out – raster with basin IDs

Return type:

2D-array of int