View on GitHub

Data Products and Interpolation

Oak Ridges Moraine Groundwater Program

Watercourse Topology

of the ORMGP region

Much of our analysis involves relating monitoring of of stream flow, point data, which exists along linear watercourse features.

Below describes an algorithm used to take an arbitrary watercourse map and determine its topology, that this the connectivity and flow direction of linearly mapped watercourse features (i.e., defining downstream vs. upstream directions).


Data Source

Ontario Hydro Network (OHN) - Watercourse provides the location of watercourses in Ontario and is offered by the Ontario Ministry of Natural Resources and Forestry.

From this, a cropped subset of streams found within our study area is exported:

Manual Adjustments

In a total of 62 locations, stream segments were manually removed in order to prevent “unnatural” flow connectivity. For instance, Mitchel Lake is the topographical high along the Trent-Severn Waterway. Naturally, water would run away in either direction toward Lake Simcoe to the West and Lake Ontario to the south. Because it’s a navigable waterway it is mapped, thus connecting the headwaters of two divergent watersheds.

Stream Segments (used here) are the longitudinal lengths of mapped watercourse, ending at each downstream confluence.

data set shown above can be found here: OHN_WATERCOURSE-export.geojson (epsg: 26917)

Defining Outlets

The above figure also shows 6 “shoreline” locations, from which the algorithm searches for any watercourse segments are touching any of these polygons.

From these selected segments, the algorithm searches for upstream segments until a head water feature is found, all the while book keeping the connections each segment has with its neighbouring upstream and downstream segments.

Defined outlets can be found here: OHN_WATERCOURSE-export-rootsel.geojson (epsg: 26917)

By defining watercourse topology, watercourse properties such as the the Horton–Strahler stream ordering system can be readily applied. Most importantly, any two sampling within our database can be grouped by shared reaches.

Topologically-correct watercourse layer: OHN_WATERCOURSE-export-segments.shp (epsg: 4326)


For computation efficiency, the Douglas-Peucker Simplify algorithm found in QGIS was applied to the watercourse layer. The simplify process has the effect dampening sinuosity, thereby shortening stream lengths. In the case, on average, segment lengths shrunk by 2%.

The simplification was set by trial and error to a 10m threshold, reducing the dataset to a manageable 500,000 vertices (X-Y locations; the points are needed for spatial queries).

Topologically-correct watercourse layer (simplified): OHN_WATERCOURSE-export-segments-simplWGS.geojson (epsg: 4326)

Vertex to vertex

For operational purposes, the topological watercourse map has been further reduced to a set of 2-point “line segments”, one for every vertex (X-Y location) used to define the entire simplified ORMGP watercourse network.

In the code chunk below presents the advantage of the topological structure described here. For instance, by providing the recursive function (below) a stream Node, all the downstream Nodes will be collected.

import ""

// GetDownstreamVertices returns a set of vertices that make up a 
// polyline marking the drainage path from the (point-like) Node provided.
func GetDownstreamVertices(fromNode *topology.Node) (xys [][]float64) {
  var recurse func(*topology.Node)
  recurse = func(usn *topology.Node) {
    xys = append(xys, {usn.S[0], usn.S[1]})
    for _, d := range usn.DS {

Added connectivity

Last manual manipulation of the data layers is performed using QGIS. Here, all of the water discharging into Lake Simcoe eventually makes its way to the Severn via Lake Couchiching.

Simply put, the downstream segment ID for all Lake Simcoe “root” segments are set to the segment ID of the Severn just at the mouth of Lake Couchiching, straight north.

Summary of generated layers

  1. OHN_WATERCOURSE-export.geojson (epsg: 26917) - Crop of original data, with 41 features manually removed for consistency see image above. (required to run algorithm)
  2. OHN_WATERCOURSE-export-rootsel.geojson (epsg: 26917) - Polygons from where the algorithm is to begin. (required to run algorithm)
  3. OHN_WATERCOURSE-export-segments.shp (epsg: 4326) - Output of the algorithm: Topologically correct watercourse layer. (as an ESRI shapefile)
  4. OHN_WATERCOURSE-export-segments-simplWGS.geojson (epsg: 4326) - The final output currently in operation.


Horton, R.E., 1945. Erosional Development of Streams and Their Drainage Basins: Hydrophysical Approach To Quantitative Morphology Geological Society of America Bulletin, 56(3):275-370.

Strahler, A.N., 1952. Hypsometric (area-altitude) analysis of erosional topology, Geological Society of America Bulletin 63(11): 1117–1142.