Tutorial: Create a longitudinal river profile

Site: OpenCourseWare for GIS
Course: QGIS Advanced Tutorials
Book: Tutorial: Create a longitudinal river profile
Printed by: Guest user
Date: Saturday, 23 November 2024, 4:19 PM

1. Introduction

In this tutorial we're going to create a longitudinal river profile using a DEM and a river layer.

The data provided with this tutorial contrains a filled SRTM 1-Arc Second DEM of the Rur catchment. We're going to download the river line vector from OpenStreetMap using the QuickOSM plugin.

After this tutorial you'll be able to:

  • Download a river from OpenStreetMap using the QuickOSM plugin
  • Sample DEM values for points at fixed distances along the river
  • Visualise the longitudinal profile using the Data Plotly plugin
  • Visualise the longitudinal profile using the Profile tool plugin

2. Download river line vectors from OpenStreetMap

In this section we're going to download all river line vectors in the study area from OpenStreetMap.

1. Start QGIS

2. In the main menu go to Project | Open From | GeoPackage...

3. In the Load project from GeoPackage dialogue browse to data_longitudinal_profile.gpkg and open the Longitudinal_profile project. Click OK.

Now you'll have a styled Rur DEM with hillshade and a catchment boundary.

The next step is to install the QuickOSM plugin.

4. In the main menu go to Plugins | Manage and Install Plugins...

5. Search for QuickOSM and click Install Plugin and Close the dialogue.

Now we're going to download river data from OpenStreetMap.

6. In the main menu go to Vector | QuickOSM | QuickOSM...

7. In the QuickOSM dialogue choose for Key waterway and for Value river. For Layer Extent choose Rur_catchment_boundary. Expand Advanced and make sure that only line features are selected. The dialogue should look like the picture below.

quickosm dialogue

8. Click Run query. Close the window when the message "Successful query, 1 layer(s) has loaded." appears.

Now you have all rivers in the study area.

In the next section we're going to select the Rur river and export it to a new layer.


3. Select and export a specific river

In the previous section we've downloaded all river line vectors in the study area from OpenStreetMap. In this section we're going to select the Rur river and export it to a new layer.

1. Click right on waterway_river and choose Open Attribute Table.

Inspect the data in the attribute table. You'll see that the name of the river is in the name field. We're going to select rivers with the name Rur and Roer. Rur is the German name and Roer is the Dutch name, so we need both to get the whole river.

2. In the attribute table click the Select features using an expression icon .

3. Type the following expression: "name"  = 'Rur' or "name" = 'Roer'

This will select all features with the name Rur or the name Roer.

4. Click Select Features and Close the dialogue.

Now you'll see these rivers selected in the map canvas (yellow) and in the attribute table (blue).

Selected river

5. Click right on waterway_river in the Layers panel and choose Export | Save Selected Features As...

6. In the Save Vector Layer As... dialogue save the layer with Layer name Rur_river to the data_longitudinal_profile.gpkg GeoPackage. Change the projection to the one of the project (EPSG: 32632) and click OK.

7. Remove waterway_river from the Layers panel.

Now we need to clean up a bit the river layer. Some sections are not part of the main river.

8. Toggle to editing mode by clicking in the editing toolbar.

9. Select the wrong parts using and press the <Delete> button. Make sure you remove all.

10. Toggle off editing by clicking again and click Save.

The river still consists of many segments. The final step to get a correct river layer is to dissolve the features.

11. In the main menu choose Vector | Geoprocessing Tools | Dissolve...

12. In the Dissolve dialogue choose Rur_river as Input layer, keep the defaults and save the output to the data_longitudinal_profile.gpkg GeoPackage with the layer name Rur_river_dissolved.

Dissolve

13. Click Run. Close the dialogue after processing.

14. Remove the data_longitudinal_profile Rur_river layer from the Layers panel.

15. Style the Rur_river_dissolved layer.  Make it dark blue.

Rur river

Now we have the complete Rur river, we can sample elevation at fixed distances along the river in the next section.

4. Sample elevation along the river

In this section we're going to sample elevation from the DEM at fixed distances along the river. In that way we can create a table from which we can draw the longitudinal river profile.

1. Open the Processing Toolbox: in the main menu go to Processing | Toolbox.

2. Choose Vector Geometry | Points along geometry.

3. In the Point Along Geometry dialogue choose the Rur_river_dissolved as Input layer. Change the Distance to 1 kilometers and save the Intepolated points to the data_longitudinal_profile.gpkg GeoPackage with the layer name Sample1km.

4. Click Run. Close the dialogue when the processing is done.

The result should look like the figure below.

Now we need to sample the elevation at each of these points.

5. In the Processing Toolbox go to Raster analysis | Sample raster values.

6. In the Sample Raster Values dialogue choose Sample1km as the Input Point Layer and DEM as the Raster Layer to sample. Expand the Advanced Parameters and type DEM_ for the Output column prefix. Save the Sampled Points the data_longitudinal_profile.gpkg GeoPackage with the layer name Sample1kmZ.

Sample raster values dialogue

7. Click Run. Close the dialogue after processing.

8. Inspect the attribute table of the result.

Now we have an attribute table with a distance field giving the distance along the river and a DEM_1 field with the elevation.

In the next section we're going to make the profile with the Data Plotly plugin.


5. Visualise the longitudinal river profile with the Data Plotly plugin

Now we have a table with the distance along the river and the corresponding elevation, we can visualise the profile using the Data Plotly plugin.

1. Install the Data Plotly plugin.

2. Click the icon to open the Data Plotly panel.

3. In the DataPlotly dialogue choose the Bar Plot as Plot type. Select Sample1kmZ as Layer with X field distance and Y field DEM_1. Edit the X field to convert distance to km.

4. Click to change the title and legend settings.

5. Fill in the dialogue as in the figure below and click Create Plot.

Now you can see the result:

In the next section we'll use the Profile tool plugin to visualise the longitudinal profile.

6. Visualise the longitudinal river profile wit the Profile tool plugin

In this section you'll learn another way to visualise the longitudinal river profile. We're going to use the Profile tool plugin.

1. Install the Profile tool plugin.

2. Click the button to load the Profile tool panel.

3. Select the DEM in the Layers panel.

4. Choose Add Layer in the Profile tool panel.

5. Select the Rur_river_dissolved layer form the Layers panel.

6. In the Profile tool panel choose under Options for Selection the Selected layer.

Profile tool

The graph shows the profile. You can play around with the other settings and export the graph as a PNG or copy the table.