geoprimsField-grade geospatial math

Flow accumulation over a DEM

How much ground drains through every cell of an elevation grid, as a count of upslope cells and an area, by D8 or by D-infinity's split flow.

Experimental: not yet fully verified. How results are checked

10

At most 10 cells drain through one cell.

Accumulation grid
Elevations
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
The area that drains through it
Its row
Its column
Cells with nowhere to go
At the window's edge
Provenance
Computed by
raster.hydrology.flow-accumulation 1.0.0, core 0.1.0
Model
D8: each cell sends its whole count to the neighbour of steepest descent, summed in topological order, so a cell's count is 1 plus the counts of every cell pointing to it. D-infinity (Tarboton 1997): a cell's flow is split between the two neighbours its angle lies between, in proportion to the angle, and cells are summed from the highest down. Area = count × cell size²
Accuracy
Exact in the arithmetic of each rule: the D8 count is an integer and satisfies the conservation identity at every cell, and the D-infinity split is the angle's own proportion
Notes
1 shown with the answer
Cites
O'Callaghan, J. F., and Mark, D. M., Computer Vision, Graphics, and Image Processing, The extraction of drainage networks from digital elevation data; Tarboton, D. G., Water Resources Research, A new method for the determination of flow directions and upslope areas in grid digital elevation models

Something look off?

Your values

Showing an example. Change anything.
More options 1
Run many at once from a CSV

Loading…

How we got thisFormula, worked example, sources, and proof

Model: D8: each cell sends its whole count to the neighbour of steepest descent, summed in topological order, so a cell's count is 1 plus the counts of every cell pointing to it. D-infinity (Tarboton 1997): a cell's flow is split between the two neighbours its angle lies between, in proportion to the angle, and cells are summed from the highest down. Area = count × cell size²

Show your work

  1. Where the water goes

    each cell's flow to the neighbour of steepest descent

    100 cells of 30 m = 0 pits

  2. Accumulation

    a cell counts itself plus everything draining through it

    100 cells = 10

The same steps an agent gets from the MCP server with explain: true.

Accuracy: Exact in the arithmetic of each rule: the D8 count is an integer and satisfies the conservation identity at every cell, and the D-infinity split is the angle's own proportion

When to use this: Use this after conditioning a DEM to find where water collects: the count is how many cells drain through each one, and the area is that count times a cell. Channels show up as the cells with high accumulation, which is what a stream threshold picks out. D8 keeps whole cells and is what a watershed needs; D-infinity splits the flow, which is smoother on a hillslope.

Limitations: The window is all the tool knows: a cell near the edge counts only what drains to it from inside the grid, so its value is a lower bound, and a basin that reaches in from outside is not counted. An unconditioned pit swallows everything that reaches it, so fill or breach the grid first; the result counts the pits it found. The grid is plane: the cell area is the cell size squared, so a geographic grid needs its cell size in meters at the latitude. The window holds at most 25,000 cells.

Worked example: A 10 by 10 ramp falling to the east. Source: add-raster-hydrology raster/hydrology, the East ramp accumulation scenario: each row reads 1, 2, 3 … 10 from west to east, counting the cell itself.

You enter

Cell size
30 m
Elevation grid
100, 99, 98, 97, 96, 95, 94, 93, 92, 91 100, 99, 98, 97, 96, 95, 94, 93, 92, 91 100, 99, 98, 97, 96, 95, 94, 93, 92, 91 100, 99, 98, 97, 96, 95, 94, 93, 92, 91 100, 99, 98, 97, 96, 95, 94, 93, 92, 91 100, 99, 98, 97, 96, 95, 94, 93, 92, 91 100, 99, 98, 97, 96, 95, 94, 93, 92, 91 100, 99, 98, 97, 96, 95, 94, 93, 92, 91 100, 99, 98, 97, 96, 95, 94, 93, 92, 91 100, 99, 98, 97, 96, 95, 94, 93, 92, 91
Method
d8

You get

Most cells draining through one cell
10
The area that drains through it
9,000 m²
Its row
1
Its column
10
Cells with nowhere to go
0
At the window's edge
A cell near the window's edge counts only what drains to it from inside the grid, so its value is a lower bound.

Review: Not yet independently reviewed by a GIS professional.

Last verified: 2026-11-06, when a maintainer last confirmed this tool's sources at the issuer. See the sources ledger.

Status: version 1.0.0, core 0.1.0. See this tool in the verification report.

Changes

Checked against: 19 golden test vectors (download the test vectors, each with its source and tolerance). See how results are checked and every source.

Sources

Terms

DEM: digital elevation model
A grid of elevations. A surface model includes buildings and canopy; a terrain model is the ground beneath them. Source: Copernicus DEM GLO-30

Experimental means this tool has not yet met the stable bar: at least 20 golden vectors, differential tests, and an independent worked example.