pyflwdir.FlwdirRaster.order_cells#

FlwdirRaster.order_cells(method: Literal['sort', 'walk', 'dfs', 'topo'] = 'walk') → None#

Order cells from down- to upstream.

Parameters:

method ({'walk', 'dfs', 'topo', 'sort'}, optional) – Method to order nodes. The default “walk” traces the nodes from down- to upstream breadth-first, holding the upstream cells of the whole network in memory in compressed sparse row layout. “dfs” traces them depth-first with the same index, which keeps each subbasin together in the sequence and may improve locality when the sequence is consumed. “topo” releases a node once all of its upstream nodes have been ordered, which needs a count per node instead of the upstream index. “sort” sorts the nodes on their rank, which can be slower for large arrays.

Notes

Every method returns the same cells, those that drain to a pit, in a sequence in which each cell other than a pit comes after the cell it drains into, which is what the flow network methods need: upstream area, basins, stream order and the like give the same result for each. The relative order of cells that do not drain into one another differs though, so labels given in sequence order (subbasins_streamorder) and the order of the features of streams change with the method, floating point accumulations can differ in the last bits, and dem_adjust and dem_dig_d4, which adjust the elevation one flow path at a time in sequence order, can give different adjustments.