A generalization of the hierarchical-queue and priority-queue methods described by previous authors. The algorithm is described using pictures in Fig. 1. Upon entry, (1) DEM contains the elevations of every cell or the value NoData for cells not part of the DEM. (2) The value NoData is less than the elevation of any cell. At exit, (1) DEM contains the elevations of every cell or the value NoData for cells not part of the DEM. (2) The elevations of DEM are such that there are no digital dams and no undrainable depressions in the landscape, though there may be flats.
Require: DEM