WhereTheWaterFlows.jl

Hydrolocial water flow routing on digital elevation models
Author mauro3
Popularity
14 Stars
Updated Last
4 Months Ago
Started In
October 2019

WhereTheWaterFlows

Build Status Build Status Coverage

This package allows to calculate water flow paths on digital elevation models (DEMs).

This package implements the D8 flow routing algorithm [1] as well as a basin-filling algorithm, also by [1]. In its implementation it uses a O(n), recursive algorithm similar as in [2]. Due to recursion it can run into a stackoverflow error on very large DEMs.

This code is reasonably fast: flow routing on a DEM of Antarctica of about 2e8 points (14000x14000) with 150000 depressions takes about 30s on my laptop (Ryzen 4750U).

Upslope area

Example of upslope area calculated in below example.

Manual

The main function of this package is waterflows, please refer to its doc-string. Here a simple example using it:

using WhereTheWaterFlows, GLMakie const WWF = WhereTheWaterFlows

"Synthtic DEM with a few maxs and mins" function peaks2(n=100, randfac=0.05) coords = range(-pi, pi, length=n) return coords, coords, sin.(coords) .* cos.(coords') .- 0.7*(sin.(coords.+1) .* cos.(coords')).^8 .+ randfac*randn(n,n) end x,y,dem = peaks2(200) area, slen, dir, nout, nin, sinks, pits, c, bnds = waterflows(dem)

log-upslope area as well as pits (sinks)

plt_area(x, y, area, pits)

catchments

plt_catchments(x,y,c)

A single catchment of some point. Choose one with large catchment:

i, j = 50, findmax(area[50,:])[2] cc = catchment(dir, CartesianIndex(i,j)) heatmap(x,y,cc) scatter!(x[i], y[j], markersize=50)

stream length

heatmap(x,y,slen)

demf = fill_dem(dem, sinks, dir)

"lake-depth"

heatmap(x, y, demf.-dem)


In the `example/` folder there are two more complicated examples.  One
showcases the ability to route several quantities at once with
self-feedback via the `feedback_fn`.

### Post-processing

There are the following function (see their docs for details):
- `catchment` -- determine the catchment of a point or a set of points
- `catchments` -- determine the catchment of several sink areas (each
  defined by a set of points)
- `catchment_flux` -- the total flux or source area in a particular catchment
- `prune_catchments` -- remove catchments smaller than a certain size
- `fill_dem` -- fill the depressions of a DEM

# References
[1] O’Callaghan, J. and Mark, D.: The extraction of drainage networks
    from digital elevation data, Comput. Vision Graph., 28, 323–344,
    1984. [download via google scholar](https://scholar.google.ch/scholar?hl=en&q=The extraction of drainage networks from digital elevation data)

[2] Braun, J. and Willett, S.D.: A very efficient O(n), implicit and
    parallel method to solve the stream power equation governing
    fluvial incision and landscape evolution
    panel [doi](https://doi.org/10.1016/j.geomorph.2012.10.008)