Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 9

Delineating watershed basins from a DEM

Open QGIS and load D:\Geomatics2014\Tutorial_14\DEM_ED50.tif.


It is a portion of a DEM of the Sant’Antioco Island, Sardinia, Italy, having a ground resolution of
10m. Our goal is to automatically delineate the watershed basins.
From the menu, select “Processing -> Toolbox”.
The “Processing” plugin is one of the most powerful features of QGIS. Thank to the work of Victor
Olaya, QGIS can integrate (more or less) seamlessly some of the most popular and stable Open
Source software for GIS and Remote Sensing, providing a standard interface to a huge variety of
procedures and processing algorithms. At a first approach, it is quite confusing for a newbie. As
Olaya himself states, you must know what you are doing…1.
It has two types of algorithm listing, the “Simplified interface” and the “Advanced Interface”.

In the “Simplified Interface” the algorithms are classified according to functionality, in the
“Advanced Interface” they are grouped according to the provider.

Calculate the flow accumulation grid


Locate the Algorithm called “Catchment area (flow tracing)”, and run it. <Use the search box, is
easier if you know what you want…>.
In the new mask, enter the name of the DEM, if it not already filled in, and leave all the other fields
with their defaults. <Don’t expect too much from the online help. Refer instead to the main
documentation of the provider, in this case SAGA, http://www.saga-gis.org>.
The algorithm will calculate many layers, but you can remove all of them but the one named
“Catchment area”. The new layers are created in a system temporary directory 2, so you don’t have
to bother with filenames if you just want to try an algorithm.

1
“Just like the manual of a word processor doesn’t teach you how to write a novel or a poem, or a CAD tutorial doesn’t
show you how to calculate the size of a beam for a building, this guide will not teach you spatial analysis. Instead, it
will show you how to use the QGIS processing framework, a powerful tool for performing spatial analysis, but it is up
to you to learn the required concepts that are needed to understand that type of analysis. Without them, there is no point
on using the framework and its algorithms, although you might be tempted to try.” Victor Olaya, from the QGIS
Training Manual, Chapter 17.
2
Normally, the temporary files are located under C: \users\<your username>\AppData\Local\Temp\processing, and are
automatically removed when you close your QGIS session.
0 0 0 0 0

0 3 2 2 0

0 0 0 1
11
0 0 1 0
15
0 2 5 1
24

The “Catchment area” layer corresponds to the flow accumulation grid <I printed it here in
negative to save ink…>. From the flow accumulation grid we can derive the drainage channels, by
setting an accumulation threshold to initiate the construction of the segments.

Build the channel network


Look for the “Channel network algorithm”, and run it. Provide the name of the DEM, the flow
accumulation grid as Initiation grid, and a threshold (use “[2] Greater then”, and try with the value
50,000). Leave all the other default values.
Also this algorithm ends up with several output layers. The most relevant one is the topmost layer, a
vector layer called “Channel Network”. Have a look.
Quite unsatisfactory, isn’t it? Yes, the network is broken down in short unconnected segments.
Why? Compare it with the flow accumulation grid. Can you see where the problems are?

Remove the sinks and do it again


The original DEM is affected by many sinks, i.e. DEM artefacts consisting of pixels whose
elevation is lower than the surrounding ones. So, before proceeding with our hydrological analysis,
we have to clean up our DEM. Remove all the layers and start again from the scratch.
But now that we know how to do, we will not use any more the temporary output files. Go to the
main menu, and select “Processing -> options and Configuration”. From the “General” options,
choose our exercise data folder as the default output destination.
Now, restart from the beginning, but this time provide meaningful names to your files <only the
relevant ones: “Catchment area” and “Channel network”, for example>. You can also go on using
the temporary files, and save the layers manually only when you are satisfied with the results.
Open the “Fill sinks” algorithm and run it. The filled DEM is now a layer that is worth to save.
You can look at the effect by subtracting the original DEM from the filled one, using the raster
calculator.
Apply again the “Catchment area (flow tracing)” algorithm, then the “Channel network”. Pay
attention to use the filled DEM, not the original, this time. Increase the channel network initiation
threshold to 400,000. <Tip: if you know that some output layers are not of interest for you, you can
uncheck the corresponding “Open output file after running algorithm” option>.
You should finally get a drainage network similar to this.

Delineate the watersheds


Now we can delineate the sub-basins corresponding to each segment of this channel network, using
as outlet points all the junction points.
Find the “Watershed basins” algorithm and run it. Provide as input the filled DEM and the drainage
network (the grid), and leave the other defaults. Save it and run.
The output you get is a raster grid, where all the pixels belonging to a watershed area have been
assigned the same integer value. You can convert it to a vector polygon layer using the algorithm
named “Vectorising grid classes” (select “[1] all classes”).
Automating the procedure
What we have done until now is a good example of a procedure that we can try to automate in order
to repeat it without having to follow all the steps one by one.
The Modeler is a very nice tool of QGIS. From the menu, open “Processing -> Graphical Modeler”.
In this new window we have to layout the procedure flow and the required input and output files.
We did this:
input a DEM  remove sinks  calculate flow accumulation  input a threshold to calculate
channel network  calculate watershed basins  convert the resulting grid to vector.
Let’s go model it.
The modeler window is divided in two areas. In the left panel you have two tags, “Inputs” and
“Algorithms”: you are already familiar with the second one.
In the “Inputs” tags, double click on “Raster Layer”. Doing so, we define an input variable, that we
call, for example, “DEM”.

Press OK, a blue object will appear in the right panel. You can move, delete or edit it.

Now, in the left panel, from the tag “Algorithms”, find and launch the “Fill sinks” algorithm. Until
now, we have only one variable (“DEM”) of the right type (Raster layer) in our model, so the “Fill
sinks” algorithm will automatically use it as the default input file. So, just press “OK”.
The algorithm will show up in the right panel, in white, showing a connection line with the DEM
variable. If you click on the “+” sign above the algorithm, you will see a list of all possible input
variables of the algorithm; the “+” sign below will show a list of all possible output files.
Let’s add the “Catchment area (flow tracing)” algorithm.
Choose the filled DEM as input, and leave all the other defaults. The algorithm will show up in the
left panel, showing a connection line with the “Fill sinks” algorithm, showing that the output of the
“Fill sinks” is the input for “Catchment area”.
Easy, isn’t it?

Ok, go on adding the other steps of the procedure, i.e. “Channel network”, “Watersheds basins” and
“Vectorising grid classes”. Just remember to:
 add another input variable to the model (the flow accumulation threshold, needed by the
“Channel network” algorithm: call it “Threshold” and assign it the default value of 400,000);
 save the result of the last algorithm by providing an output file name (in my example, I named it
“Basins”);
 pay attention in selecting the right input files for each algorithm.
Once you have finished, enter a Model name (in my example, “DEM_to_Basins”) and a Group name
(“My_Models”), and save it in the proposed default QGIS location. Test it by clicking on the “Run
Model” icon.
You can try to arrange the different boxes in order to improve the clearness and the readability of
the model. My figure below is not a great example…
Our model will now show in the Processing Toolbox, and we can run it by simply double-clicking.

You might also like