# how and why watercourses are ranked in geographical sciences

Hello Habr! I suggest diving into one fascinating hydrological topic – ranking river systems. Under the cut I tried to provide material useful both for geographers who are faced with the problem of ranking a vector layer of rivers using geographic information systems (GIS), and for all concerned people who have sometimes seen “beautiful rivers” on the map, but do not know how exactly they are designed in cartographic materials. Let's start with a picture:

Now the question is: which part looks better? – For me, the one at the bottom (b).

In fact, the second visualization is more correct from the point of view of common sense. The more tributaries flow into the river bed, the wider and fuller it will be. For example, one of the largest rivers in the world, the Nile, at its source high in the mountains barely resembles the mighty river in its lower reaches: with each kilometer of its way to the Mediterranean Sea, the river absorbs more and more tributaries and becomes more and more full-flowing.

The map above (Figure 1b) was prepared based on information about the structure of the river network. In this post I would like to discuss how this additional information about rivers can be obtained and what tools can be used for this.

What is a river

First, let us explain how information about rivers is represented in geographic information systems. In cartography and Earth Sciences, rivers are usually represented as a linear vector layer: each section of the river is depicted as a linear object with some characteristics. For example, the length of the section, its geographic coordinates (object geometry), soil type, average depth, flow velocity, etc. (Animation 1).

So when you see a river on a map, you see a set of these simple geometric primitives (separate rows in the attribute table) collected into one large system. Different colors can be used to visualize the characteristics of the segments (Figure 2).

Specialized software is often used to visualize spatial objects and create maps, such as ArcGIS (proprietary GIS) or QGIS (open source).

Structure of rivers

Information for recording in the attribute table for rivers is collected in different ways: remote sensing data, expeditions, automatic sensors at hydrological stations, etc. are used. As for information about the structure of the river: it is usually assigned by a specialist at the very last moment, when he sees on the map what the whole system looks like. For example, a researcher can add a new column to the attribute table of a vector layer, in which he assigns a rank to each segment of the river (Figure 3).

Now we see that Figure 3 resembles the diagram from the beginning of the article (Figure 1b). But the question arises: by what principle can such values ​​be assigned? – To cut the story short, the answer is: there are many. There are several generally accepted systems for ranking watercourses in hydrology – see, for example, the page Wikipedia Stream order or for a deeper dive, the book “Fundamentals of river hydrology and hydrobiology”. Below are some approaches that I have used myself (Figure 4).

What is this for

Now it's time to answer the question of why such ranking systems are needed. There are two reasons:

• Visualization – using rank as an attribute of the size of a linear feature on a map, you can create beautiful cartographic materials (Figure 1);

• Further analysis.

Developing the second point: knowledge of the river network structure can be combined with other characteristics, for example, to identify the following patterns (Figure 5). As can be seen from the figure, as the segment rank increases, the water flow velocity decreases.

What tools can be used to rank watercourses

Ranking large river systems manually is very time-consuming, so specialized tools have been developed to automatically calculate ranks. There are two fundamentally different ways:

• Ranking of watercourses using raster data (digital elevation model);

• Ranking of watercourses by vector layers.

It was described above how to assign ranks to vector layers. However, spatial data is sometimes presented in a different format – as rasters (matrices) (Figure 6). Digital elevation models (matrices in which each pixel has a certain size, for example 90 by 90 meters, and the value of the altitude above sea level, which is stored in each cell of this matrix) are especially often used when calculating river ranks.

The digital elevation model is used to calculate the flow direction matrix and flow accumulation. This is the principle used, for example, by the tool Stream Order (Spatial Analyst) in ArcGIS. In this post I will not describe in detail how such an algorithm works, since the official documentation has quite good visualizations and descriptions (if you want to know more, visit the function page Flow Direction). Below I have listed some tools that can be used to obtain the Strahler order using raster data:

However, all this requires a lot of manipulation of raster data. What if you already have a vector layer? (This might happen if you have, for example, a river network vector layer downloaded from OpenStreetMap). Let's take a closer look!

How to get Shreve, Strahler and Topological Order on a vector layer using QGIS

While working four years ago, my colleagues and I implemented an algorithm that allows us to calculate the Shreve, Stragler, and Topological order based only on a vector layer and an endpoint (the point where the river system ends and flows into a lake/sea/ocean). The first version of the algorithm is described in more detail in my first article on Habr: “River network segment ranking algorithm using graphs for geoinformation analysis” (wiping away a tear of nostalgia). The algorithm itself was prepared as an open-source plugin Lines Ranking for QGIS and supplied documentation. There will be no detailed description of how exactly the algorithm works here, I will limit myself to listing the actions that need to be performed to carry out the calculation:

1. Load a vector layer into a QGIS project

2. Reproject to metric projection

3. Select the point on the map where the river flows into

4. Visualize the result using the size or color parameter (Figure 7)

Thus, we have delved a little deeper into the topic of watercourse ranking in hydrology (river network appraisal) and learned how to obtain ranks from source data (raster or vector) using various tools. Having obtained information about the river structure, you can prepare beautiful and understandable visualizations or continue the analysis by combining the obtained information with other characteristics of the river.