pyflwdir.FlwdirRaster.upstream_area#
- FlwdirRaster.upstream_area(unit: Literal['m2', 'ha', 'km2', 'cell'] = 'cell', parallel: bool = False, partition_plan: PartitionPlan | None = None, threads_per_process: int | None = None, layering: Literal['asap', 'cfds', 'alap'] = 'cfds', manner: Literal['push', 'pull'] = 'push', start_method: str = 'spawn') ndarray[source]#
Return the upstream-area raster for the flow directions.
Areas are returned in the units specified by unit.
- Parameters:
unit ({'m2', 'ha', 'km2', 'cell'}) – Upstream-area units: square metres (‘m2’), hectares (‘ha’), square kilometres (‘km2’), or cells (‘cell’), by default ‘cell’.
parallel (bool, optional) – Accumulate one layer at a time in threads, by default False.
partition_plan (PartitionPlan, optional) – How to divide the raster over processes, made with
partition(). With a plan, each part is accumulated in its own process with threads, one process a part, and any mainstem sections are accumulated after the processes finish. Without one, the default, everything runs in this process. A plan can be reused for any number of calls on the same flow directions. It needsparallel=Trueand the default layering and manner, and it is checked against the flow directions first.threads_per_process (int, optional) – Threads inside each process, used only with a partition_plan. By default the available threads are divided over the processes. Without a plan, the threads are the current Numba thread count.
layering ({'asap', 'cfds', 'alap'}, optional) – Layering used with
parallel=True, by default"cfds".manner ({'push', 'pull'}, optional) – Propagation manner used with
parallel=True, by default"push". Push needs the conflict-free"cfds"layering; pull is safe with all three.start_method (str, optional) – Multiprocessing start method, used only with a partition_plan, by default
"spawn". With"spawn", call it from an importable script, below anif __name__ == "__main__":guard.
- Returns:
Upstream area in unit; no-data cells are set to -9999.
- Return type:
2D array