OPM · Hydrology Course
ChaptersChapter 2

title: "Chapter 2 — Watershed Delineation" chapter: 2

Chapter 2 — Watershed Delineation

Every raindrop that falls on land belongs to exactly one drainage basin. The invisible line separating basins — the watershed divide — can be drawn automatically from any DEM using the flow-direction grid we built in Chapter 1.


2.1 — What Is a Watershed?

A watershed (or catchment) is the set of all cells whose water eventually reaches a given pour point — the outlet where flow leaves the area of interest. The contributing area AA at a pour point (i,j)(i,j) satisfies:

A(i,j)=(r,c)s.t.downstream path(r,c)(i,j)Δx2A(i,j) = \sum_{\substack{(r,c)\;\text{s.t.}\\\text{downstream path}\;(r,c)\to(i,j)}} \Delta x^2

Every cell upstream of (i,j)(i,j) is part of its watershed; every cell that drains elsewhere is not.

Click any cell to trace its path downstream ("Trace Down"), or to light up every cell that drains through it ("Show Watershed"). Left-click a cell in the watershed mode to relocate the pour point; check "✏️ Edit Terrain" to modify elevations.

Watershed Concept

Click any cell — trace its path or see its full contributing area

7654654354324321

Click any cell to trace its flow path to the outlet.

Tip: In watershed mode, click cell (3,3) to see all 16 cells light up — they all drain to the corner.

Notice how clicking the outlet corner (3,3) highlights all 16 cells — the entire grid is one watershed when there is a single outlet. Move the pour point inland to select only the contributing sub-area.


2.2 — The Upstream Tracing Algorithm

D8 arrows point downstream. To find a watershed we must follow them backwards — a Breadth-First Search (BFS) upstream.

watershed ← {pour_point}
queue     ← [pour_point]

while queue not empty:
    (r, c) ← queue.dequeue()
    for each neighbour (nr, nc) of (r, c):
        if flow[nr][nc] points INTO (r, c):   # arrow tip lands on (r,c)
            watershed.add(nr, nc)
            queue.enqueue(nr, nc)

The key test: does flow[nr][nc] point into (r,c)? In D8 terms, nr + Δr = r and nc + Δc = c.

Click any cell to place the pour point, then press "▶ Delineate" to watch BFS expand step by step. The queue panel on the right shows pending cells (amber = currently examined); the step log records every neighbour check.

BFS Upstream Delineation

Click a cell to set the pour point, then animate the upstream search

70,060,150,240,361,051,141,231,352,042,132,222,343,033,123,213,3

BFS Queue

Click a cell to set the pour point

Step Log

No steps yet

Controls

Medium
SlowFast

Select a pour point

We never follow arrows forward — we look for neighbors whose arrow points BACK to us.

BFS visits every cell at most once, so delineation runs in O(MN)O(MN) — a full continental DEM with 10⁸ cells takes only seconds.


2.3 — Divides, Multiple Catchments & Stream Order

Real landscapes contain many basins separated by divides — ridgelines where adjacent cells flow in opposite directions.

Strahler order:O(AB)={max(OA,OB)+1if OA=OBmax(OA,OB)otherwise\text{Strahler order:}\quad O(A \cup B) = \begin{cases} \max(O_A, O_B) + 1 & \text{if } O_A = O_B \\ \max(O_A, O_B) & \text{otherwise} \end{cases}

Tab 1 colours the two basins and marks divide cells in orange. Tab 2 animates two raindrops released on either side of the ridge — they flow to opposite outlets. Tab 3 shows the Strahler stream order: order 1 at headwaters, order increases only when two streams of the same order merge.

Catchment Maps & Divides

Ridge terrain — two basins separated by a divide

Left-click a cell to raise elevation · Right-click to lower · Watch basins reflow live.

5995488437732662
Basin A: 8 cells|Basin B: 8 cells|Divide: 8 cells share border
= outlet cell  · dashed orange border = divide cell  ·  arrows = D8 flow direction

The ridge terrain splits cleanly into two 8-cell basins. Drag the FA threshold slider in Tab 3 to see how the stream network grows as you lower the minimum contributing area.


2.4 — Explore Full Terrain

Switch between five 8×8 presets — valley, mountain, ridge, slope, basin — and explore how terrain shape controls basin geometry and stream structure.

Toggle Strahler Colors to see stream order superimposed on the watershed shading.

Explore Watersheds

Edit terrain · set pour points · discover drainage basins

2233332223455432346776433579975335799753346776432345543222333322

Left-click to raise · Right-click to lower

Preset Terrain

Interaction Mode

Overlays

Stream Threshold

Min FA (τ):τ = 4

— Set a pour point (📍 mode) —

Hover: —

Elevation Ramp

LowHigh

2.5 — For Grad Students

Pfafstetter coding (1997) — hierarchical basin numbering 1–9; odd digits = tributary basins, even digits = mainstem inter-basin segments. Up to 9 nesting levels encode every sub-basin globally without overlap:

Pfafstetter code of sub-basin=Pparent10+k,k{1,,9}\text{Pfafstetter code of sub-basin} = P_{\text{parent}} \cdot 10 + k, \quad k \in \{1,\ldots,9\}

Hypsometric curve — cumulative fraction of area above elevation hh:

HI=01h(a)dazˉzminzmaxzmin\text{HI} = \int_0^1 h^*(a)\,da \approx \frac{\bar{z} - z_{\min}}{z_{\max} - z_{\min}}

HI > 0.6 → young, actively dissected landscape; HI < 0.35 → peneplain (monadnock stage).

Flat-area routing — Wang & Liu fill creates artificial flats where D8 is ambiguous. Solutions: (1) Priority-Flood + ε\varepsilon-gradient (Barnes 2014); (2) least-cost-distance routing (LDD); (3) D∞ on the original unfilled DEM.

Algorithmic complexity:

StepAlgorithmComplexity
DelineationUpstream BFSO(MN)O(MN)
Catchment mapBFS per outletO(KMN)O(K \cdot MN)
Strahler orderTopo-sort + one passO(MNlogMN)O(MN \log MN)
PfafstetterRecursive delineationO(MNlogMN)O(MN \log MN)

Summary

ConceptRuleKey point
WatershedAll cells draining to a pour pointFound by upstream BFS, not downstream tracing
BFS delineationCheck if flow[nr][nc] points into (r,c)O(MN)O(MN); each cell visited once
DivideCells whose neighbours belong to different basinsRidge cells — one raindrop, two fates
Flow accumulationFA ≥ τ defines the channel networkLarger τ → fewer, longer streams
Strahler orderConfluence of equal orders increments orderQuantifies network branching complexity

Chapter 3 → Rainfall–runoff processes — how precipitation becomes streamflow through Hortonian overland flow, saturation-excess, and infiltration.