Skip to contents

D8FlowDirection: steepest descent \((z - z_k)/d_k\) coded 1 E, 2 SE, 4 S, 8 SW, 16 W, 32 NW, 64 N, 128 NE, 0 for pits and flats, ties to the first code (O'Callaghan and Mark 1984). FlowAccumulation: cells (or weights) draining through each cell, itself included. Watershed: 1 for cells draining to outlet (row, column). Identical to the Python arm morie.fn.demops.

Usage

D8FlowDirection(dem, res = 1)

FlowAccumulation(flowdir, weight = NULL)

Watershed(flowdir, outlet)

Arguments

dem

Elevation matrix.

res

Cell size.

flowdir

D8 code matrix.

weight

Optional weight matrix.

outlet

Row and column of the outlet (1-based).

Value

Matrix.

References

O'Callaghan, J. F. and Mark, D. M. (1984). The extraction of drainage networks from digital elevation data. Computer Vision, Graphics, and Image Processing 28, 323-344.

Examples

D8FlowDirection(rbind(c(3, 3, 3), c(2, 2, 2), c(1, 1, 1)))
#>      [,1] [,2] [,3]
#> [1,]    4    4    4
#> [2,]    4    4    4
#> [3,]    0    0    0
FlowAccumulation(rbind(c(4, 4), c(1, 0)))
#>      [,1] [,2]
#> [1,]    1    1
#> [2,]    2    4
Watershed(rbind(c(4, 4), c(1, 0)), c(2, 2))
#>      [,1] [,2]
#> [1,]    1    1
#> [2,]    1    1