We present a new algorithm for solving the common problem of flow trapped in closed depressions within digital elevation models, as encountered in many applications relying on flow routing. Unlike other approaches (e.g., the Priority-Flood depression filling algorithm), this solution is based on the explicit computation of the flow paths both within and across the depressions through the construction of a graph connecting together all adjacent drainage basins. Although this represents many operations, a linear time complexity can be reached for the whole computation, making it very efficient. Compared to the most optimized solutions proposed so far, we show that this algorithm of flow path enforcement yields the best performance when used in landscape evolution models. In addition to its efficiency, our proposed method also has the advantage of letting the user choose among different strategies of flow path enforcement within the depressions (i.e., filling vs. carving). Furthermore, the computed graph of basins is a generic structure that has the potential to be reused for solving other problems as well, such as the simulation of erosion. This sequential algorithm may be helpful for those who need to, e.g., process digital elevation models of moderate size on single computers or run batches of simulations as part of an inference study.

Finding flow paths on a topographic surface represented as a digital elevation model (DEM) is a very common task that is required by many applications in domains such as hydrology, geomorphometry, soil erosion, and landscape evolution modeling, and for which various algorithms have been proposed for either gridded DEMs

Closed depressions may arise in DEMs because they are real topographic features or result from interpolation error during DEM generation or its lack of resolution. These spurious local minima need to be resolved because they disrupt flow routing, produce hydrologically unrealistic results, or introduce artificial singularities that may result from a sudden, unrealistic jump in computing discharge. Flow routing is often corrected by filling depressions

Although not having a linear time complexity, the most recent algorithms of depression removal – e.g., the Priority-Flood algorithm and its variants

Yet, in some applications flow path enforcement still remains the main bottleneck. This is for example the case in many landscape evolution models (LEMs) simulating an evolving topography

We have developed a new method of flow enforcement that is based on the explicit building of a graph of drainage basins (possibly encompassing depressions) and the computation of the flow paths both within and across those basins. This idea was first introduced in a

Simulation of the evolution of an escarpment over

After a detailed presentation of the different steps of the method, we will show in the sections below through some results how our algorithm behaves and performs compared to existing solutions of flow path enforcement. We will finally discuss the assets and limitations of our method, with some focus on landscape evolution modeling applications.

The

We propose an algorithm that updates the receivers of a subset of

There exists a single boundary node

This flow path does not contain any cycle; i.e., each node appears only once in

The receivers defining

Our method is essentially based on the computation of a graph connecting adjacent drainage basins. We define a

To better explain the problem that we want to solve, we consider a filled topography as the result of an ideal physical process where a perfectly fluid material has been poured onto an impermeable ground and stabilized at steady state. For a node

The energy of the nodes should be changed to

Illustration of the inputs and the first steps of the proposed flow routing algorithm.

One may break the problem of flow path enforcement down to three smaller problems: find the spill of each depression, force the flow within the depressions to be routed toward their respective spill, and ensure that the flow through the spills is properly routed into adjacent basins. The proposed algorithm addresses this problem in an explicit manner and can be divided into three main stages.

Compute the basins and link all pairs of adjacent basins (Fig.

Select only some of the basin links computed at the previous stage and orient them such that the flow is routed consistently across adjacent basins, from inner basins toward the boundary basins (Fig.

Update the flow receivers. Using the links selected at the previous stage, we update (only some of) the receivers to enforce the flow both within and across inner basins so that it is ensured to finally reach the boundary basins and their associated boundary nodes. We propose three different methods (one may choose a method over another depending on the specific problem to solve).

Each of these stages processes the whole DEM, and as such are run only once for a given topography. They are each detailed in the next sections.

This first stage consists in first assigning a basin identifier,

Then, the

The sets of basins

This second stage tackles the problem of selecting the right subset of links so that we obtain consistent flow paths on the basin graph.
To illustrate the proposed solution, let us start from an inner basin. If it is filled with water, the water level will rise until it finds a pass where water eventually pours into another, adjacent basin. The associated link is then called the

If we add to the basin graph a virtual basin (let us call it

where

We propose two algorithms for the computation of a minimum spanning tree. Kruskal's algorithm is very generic and simple with a log-linear complexity. We also propose a second algorithm, which leverages the planar nature of the basin graph to reach a linear complexity.

Kruskal's algorithm

Create an equivalence class containing a single element.

Merge two equivalence classes.

Get the equivalence class of an object.

The optimal implementation of the union–find structure provides a

The problem of finding the minimum spanning tree is known to have a

A special case may arise when the basin graph is computed from a grid of eight-connectivity. In this case, the edges of the graph may cross each other due to the diagonal connectivity, possibly making the basin graph not perfectly planar. This is, however, rather unlikely as it implies that two passes connecting different basins are found on the two diagonals connecting four adjacent nodes of the grid. Furthermore, this issue does not impact the correctness of the algorithm. Only the linear complexity is not formally proven. Because it is not planar, the case of an eight-connectivity grid would fall in the second category mentioned by

The basin tree obtained at the previous stage must be oriented before routing the flow from inner basins to the boundary basins. This is achieved by traversing the tree in the reverse order (i.e., starting from the boundary basins) and labeling the two nodes of each pass, one as

The last stage then consists in updating the flow receivers so that any flow entering an inner basin is ensured to leave the basin through

The idea here is to mimic the effect of a river carving a narrow trench between the bottom of the depression and the spill: a new, single path is computed from the local minimum to the pass. In fact, the most direct path is already defined by the flow receivers that were computed initially, but it is in the reverse order, i.e., from the pass to the local minimum. Hence, it is trivial to follow this path and progressively revert the receivers until the local minimum is reached (see Algorithm 3).

Unlike the previous method, we update here the receivers as if the depressions were completely filled by some material. We define a procedure that starts at a pass and then progressively parses all neighbor nodes in a breadth-first order as long as these are below water level, at the same time updating the receiver of the current parsed node as being one among its neighbors that has already been parsed (see Algorithm 4). We repeat this procedure for all depressions by traversing the basin tree from the boundary basins to the most inner ones so that accurate water level values can be computed during the procedure. Receivers are chosen according to a cost function that we define here as the minimal Euclidean distance between a node and

Our algorithm is run under different settings to illustrate its behavior and compare it with some other state-of-the-art methods. Most of the examples below are shown within the context of landscape evolution modeling, using a simple model of block uplift vs. channel erosion by the stream power law. This model simulates the evolution of the topographic surface

Our algorithm of flow enforcement run on a synthetic case.

The behavior of our algorithm of flow path enforcement is best illustrated using a simple synthetic topography as input. A set of

Demonstration of the effect of flow path enforcement on erosion, using different strategies of flow receivers “correction” within inner basins.

Figure

In this specific case, the algorithm updates the receivers of only three nodes: (1) one of the neighbors of the boundary node, which here corresponds to the spill of the closed depression,
(2) one of the neighbors of the spill that, together with the spill, forms the pass connecting the depression to the boundary node, and (3) the local minimum at the bottom of the depression. The new assigned receivers are for (1) the boundary node itself, (2) the spill, and (3) the other node of the pass. We can see in Fig.

Unlike the former strategy and as expected, Fig.

Using the depression filling strategy, flow receivers are updated over a large area of the depression as if the water surface was replaced by a very gentle slope toward the spill. As a result, erosion affects a great part of the modeled domain, with the emergence of a star-like pattern centered at the spill (Fig.

Choosing one strategy over another greatly depends on the specific application. For example, the simple correction strategy may be acceptable if one assumes that no erosion could happen in depressions below the water level. However, interrupted drainage area patterns within the depressions may be problematic when used with erosion algorithms like the FastScape model, which uses an implicit time scheme for solving the stream power law but still treats drainage area explicitly, resulting in too slow opening of the closed depressions by erosion. The depression carving or depression filling strategies generally yield better results in the latter case. These two strategies have, however, contrasting behaviors and choosing one or the other will depend on several criteria such as the size (i.e., depth vs. volume) of the depressions.

Results from benchmarks assessing the performance of our algorithm for local minima resolution – including both

To assess the performance of our algorithm, we have run multiple benchmarks under various settings. Although these benchmarks mostly take place in the framework of landscape evolution modeling, they provide results that may be useful in other applications too. Note that for better readability, we present here only the results from benchmarks applied to a fixed grid of 16

We have run benchmarks for our algorithm – including the two variants for computing the minimum spanning tree but considering only the depression filling strategy – as well as for three other state-of-the-art algorithms of local minima resolution, respectively proposed by

In a first set of benchmarks, we create an input topography by running the FastScape model (starting from an initial flat surface with small random perturbations) until steady state is reached (the uplift rate is set to

In a second set of benchmarks, we analyze the performances of the algorithms for local minima resolution through full simulations of landscape evolution. We run the FastScape model over 20 time steps of 10 000 years each, starting from a flat topography with small random perturbations (thus containing many local minima) and using fixed boundary conditions, i.e., boundary nodes all along the grid boundaries. The simulations are all based on a uniform uplift rate of

We focus our discussion on an in-depth analysis of the differences in performance obtained by the different state-of-the-art algorithms, as reported in the section above.

We also derive the complexity of our algorithm taking its stages separately. The first and last stages, i.e., the computation of the basin graph and the update of flow receivers, are both bounded by

The complexities of the algorithms that we have derived here are all consistent with the benchmark results shown in Fig.

For all the algorithms compared here, the memory consumption grows linearly with the DEM size.

We have presented here a new algorithm for flow path enforcement in topographies with depressions. We have designed this algorithm within the framework of landscape evolution modeling and we have demonstrated through benchmarks that, in this scope, it may greatly improve performance compared to other state-of-the-art solutions. The potential of this algorithm is, however, not limited to landscape evolution models. On a broader scope, the basin graph and its minimum spanning tree are generic structures that other applications may leverage, possibly through derived quantities such as the water level of each depression. We propose here optimal methods to compute those structures and quantities. Despite the fact that our algorithm is rather complex and requires some work to be properly implemented, it is designed in a composable way such that it is easy to reuse one or several of its components. Adding new features like alternative strategies of flow path enforcement within the depressions would require only little effort, too.

While being versatile, this new algorithm does not provide a universal solution to the problem of flow routing both within and across closed depressions. Perhaps its main limitation is the assumption of single- direction flow, i.e., each node has one unique flow receiver. Adding full support for multiple-direction flow (MDF) without losing in performance is rather difficult and would require a fair amount of redesign work at each of the three stages of the algorithm:

Basin computation should take into account divergent flow (basin labels are not unique for grid nodes located on drainage divides).

It should be theoretically possible to route the outflow from an inner basin into more than one of its adjacent basins (this is currently not possible using a minimum spanning tree computed from the basin graph).

Alternative, MDF-compliant methods should be implemented to update the flow receivers within the depressions.

Another limitation of this algorithm is its sequential implementation. Further work is needed to adapt it so that it could be run on modern, multi-core, and/or GPU-based architectures. Still, many use cases would benefit from the current implementation. These include processing datasets of moderate size on a single computer or running batches of simulations or analysis pipelines, e.g., in the context of sensitivity analyses or inferences on model parameters.

Algorithm 5 finds which basin each node of the grid belongs to by assigning them a label. One unique label is defined (here by an integer) for each basin.

Algorithm 6 creates the graph of basins by linking together each pair of adjacent basins. It also finds the passes of lowest elevation between those adjacent basins. Note that the links are undirected, such that Links.contains((

The code used for the implementation of the algorithm, examples, and benchmarks presented in this paper is available here:

GC designed the algorithm and implemented it including the examples/benchmarks presented in this paper; BB also worked on the implementation. GC and BB worked on the redaction of the paper with contributions by JB, and all authors contributed to fruitful discussions throughout this study, especially JB, who provided many test conditions and use cases.

The authors declare that they have no conflict of interest.

We thank the reviewers for their helpful comments that greatly improved this article.

This paper was edited by Greg Hancock and reviewed by two anonymous referees.