pyflwdir.dem.fill_depressions#
- pyflwdir.dem.fill_depressions(elevtn: ndarray, outlets: Literal['edge', 'min'] = 'edge', idxs_pit: ndarray | None = None, nodata: float = -9999.0, max_depth: float = -1.0, elv_max: float | None = None, connectivity: int = 8) tuple[ndarray, ndarray][source]#
Fill local depressions in elevation data and derived local D8 flow directions.
Outlets are assumed to occur at the edge of valid elevation cells outlets=’edge’; at the lowest valid edge cell to create one single outlet outlets=’min’; or at user provided outlet cells idxs_pit.
Depressions elsewhere are filled to their lowest pour-point elevation. If the pour point depth is greater than or equal to max_depth, a pit is set at the depression’s local minimum elevation.
Based on: Wang, L., & Liu, H. (2006). https://doi.org/10.1080/13658810500433453
- Parameters:
elevtn (2D array) – elevation raster
outlets ({'edge', 'min'}, optional) – Initialize outlets at valid edge cells (‘edge’, default) or use only the lowest-elevation valid edge cell (‘min’). If idxs_pit is provided, outlets controls whether all supplied outlets or only the lowest-elevation one are used.
idxs_pit (1D array of int, optional) – Linear indices of user-specified outlet cells. By default, outlets are selected from the valid raster edge.
nodata (float, optional) – No-data value, by default -9999.0.
max_depth (float, optional) – Maximum pour point depth. Depressions with a larger pour point depth are set as pits. A negative value (default) represents an infinitely large pour point depth causing all depressions to be filled.
elv_max (float, optional) – Maximum elevation for outlets, only used with outlets=’edge’. By default None.
connectivity ({4, 8}, optional) – Number of neighboring cells to consider.
- Returns:
elevtn_out (2D array) – Depression-filled elevation raster.
d8 (2D array of uint8) – D8 flow directions, with no-data cells encoded as 247.