pyflwdir.FlwdirRaster.layer_cells#
- FlwdirRaster.layer_cells(method: Literal['asap', 'cfds', 'alap'] = 'cfds') tuple[ndarray, int]#
Group cells into dependency-free layers.
- Parameters:
method ({'asap', 'cfds', 'alap'}, optional) – Layering method, by default
"cfds"."asap"places every cell as soon as its upstream dependencies allow."alap"delays cells within each basin to balance later layers."cfds"starts from"asap"and also prevents two cells in one layer from sharing a downstream receiver, so a threaded push is race-free.- Returns:
layers (ndarray of int32) – Layer index per cell, shaped like the flow-direction object.
-1marks cells outside the network or cells that cannot be scheduled because of a loop.n_layers (int) – Number of layers.
Notes
Threaded upstream accumulation (
parallel=Trueinaccuflux()andFlwdirRaster.upstream_area()) is the only computation that uses layers, and it builds its own. Calling this method only returns them: it does not make any other method run in parallel.References
The three layerings and their implementations come from FlowTopo:
Jiang, L., Wu, H., Chen, W., Huang, Z., Yamazaki, D., Yang, T. and Li, L. (2026). FlowTopo (v1.0.0). Zenodo. https://doi.org/10.5281/zenodo.22227621