geoprimsField-grade geospatial math

Longest flow path to a point

The longest way water travels to the cell you pick, cell by cell, with the distance along it and the height it falls.

Experimental: not yet fully verified. How results are checked

270m

Water travels 270 m to that cell.

The path
StepRowColumnElevation
111100.000 m
21299.000 m
31398.000 m
41497.000 m
51596.000 m
61695.000 m
71794.000 m
81893.000 m
91992.000 m
1011091.000 m
Where it runs
LinkDistance eastDistance south
115.000 m15.000 m
145.000 m15.000 m
175.000 m15.000 m
1105.000 m15.000 m
1135.000 m15.000 m
1165.000 m15.000 m
1195.000 m15.000 m
1225.000 m15.000 m
1255.000 m15.000 m
1285.000 m15.000 m
Drop
Average slope along it
Cells along it
Its top row
Its top column
Provenance
Computed by
raster.hydrology.longest-flow-path 1.0.0, core 0.1.0
Model
The longest chain of D8 pointers ending at the outlet, found by walking the pointers upstream and keeping, at each cell, the longest branch above it. Length sums the cell size along sides and √2 times it along diagonals between cell centers; the drop is the path's first cell above the outlet, and the average slope is the drop over the length
Accuracy
Exact in the arithmetic of the rule over the window given: the path is the longest chain the pointers allow, and its length is the walked chain of cell centres
Notes
1 shown with the answer
Cites
Jenson, S. K., and Domingue, J. O., Photogrammetric Engineering and Remote Sensing, Extracting topographic structure from digital elevation data for geographic information system analysis; O'Callaghan, J. F., and Mark, D. M., Computer Vision, Graphics, and Image Processing, The extraction of drainage networks from digital elevation data

Something look off?

Your values

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

Loading…

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

Model: The longest chain of D8 pointers ending at the outlet, found by walking the pointers upstream and keeping, at each cell, the longest branch above it. Length sums the cell size along sides and √2 times it along diagonals between cell centers; the drop is the path's first cell above the outlet, and the average slope is the drop over the length

Show your work

  1. Upstream from the outlet

    the longest branch above each cell, kept all the way up

    100 cells in the window = 10 cells on the path

  2. Its length

    the cell size along a side, √2 times it along a diagonal

    9 steps of 30 m = 270 m

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

Accuracy: Exact in the arithmetic of the rule over the window given: the path is the longest chain the pointers allow, and its length is the walked chain of cell centres

When to use this: Use this for the hydraulic length a time-of-concentration formula asks for: the longest way water travels to a culvert, a gauge, or a basin outlet, with the height it falls on the way. Give the conditioned grid, the cell size, and the outlet's row and column; add the grid's north-west corner to get the path placed in latitude and longitude for a map.

Limitations: The path follows the D8 staircase, so it reads longer than a smooth channel, most of all across a slope that faces between two of the eight directions. The window bounds it: a path that reaches the edge is as much as the data holds. An interior pit cuts a path short, so condition the grid first. The grid is plane, so a geographic grid needs its cell size in meters at the latitude. The window holds at most 25,000 cells.

Worked example: The path to the east edge of a ramp of 30 m cells. Source: add-raster-hydrology raster/hydrology, the Ramp path scenario: 270 m along the row, falling 9 m.

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
Outlet column
10
Outlet row
1

You get

Path length
270 m
Drop
9 m
Average slope along it
0.03333
Cells along it
10
Its top row
1
Its top column
1

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: 15 golden test vectors (download the test vectors, each with its source and tolerance). See how results are checked and every source.

Sources

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