Tutorial: Create a Stage Volume Curve
Site: | OpenCourseWare for GIS |
Course: | QGIS Advanced Tutorials |
Book: | Tutorial: Create a Stage Volume Curve |
Printed by: | Guest user |
Date: | Sunday, 22 December 2024, 5:01 AM |
1. Introduction
A Stage Volume Curve or Stage Storage Curve can be used to read which volume of a lake or a pit belongs to a certain water level. It's much easier to measure the water level than the volume, so once the curve is created the volume can be determined in an easy way.
In this tutorial we'll create a Stage Volume Curve for an open pit Lignite mine, but the method is the same for lakes.
After this tutorial you'll be able to
- calculate the volume below a specific elevation in a DTM
- create a Stage Volume Curve using PyQGIS
2. Calculate the volume below a specific elevation
First we'll explore a processing tool to calculate the volume below a specific elevation in a DTM.
1. Open QGIS.
2. In the main menu go to Project | Open From | GeoPackage.
3. In the Load project from GeoPackage dialogue browse to the provided data_stagevolume.gpkg GeoPackage and open the StageVolume project.
This project has an SRTM 1-Arc Second DEM reprojected to UTM Zone 32N and clipped to the area around the open pit mine. The DEM has been styled with a colour ramp and is blended with a rendered hillshade.
4. Go to Processing | Toolbox to open the Processing Toolbox panel.
5. In the Processing Toolbox choose Raster analysis | Raster surface volume.
6. In the Raster Surface Volume dialogue choose DTM as Input layer, keep Band number as it is and here we keep Base level 0 m, because we want to calculate the volume that is below 0 m. We do that by changing the Method to Count Only Below Base Level. The Surface volume report is an html file. Give it the name volumebelowzero.html. The Surface volume table is a dbf file. We can't choose a dbf file so we save it as volumebelowzero.shp.
7. Click Run.
The Log tab gives the result: 'VOLUME' : -1155480399.7627096
It also gives an error in red. This is because it doesn't create a shapefile but a dbf file. So you can ignore this error.
8. Click Close to close the dialogue.
At the bottom of the Processing Toolbox you can find the Results Viewer.
9. Double click on the Surface volume report or the html link (it links to the same). It will open in your browser. Check the results.
10. Drag the volumebelowzero.dbf file from the Browser panel to the map canvas.
11. Click right on the volumebelowzero table in the Layers panel and choose Open Attribute Table to check the result.
12. Repeat from step 5 for some other elevations.
In the next section we're going to calculate the volumes for many elevations and store the values in one table.
3. Create a Stage Volume Table
In the previous section we've calculated the volume corresponding to a specific elevation one by one.
In this section we're going to iteratively calculate the volume for a range of elevations and store the results in one table. For that purpose we need to write a PyQGIS script around the Raster Surface Volume tool.
All processing tools that you've run are stored in the history of the Processing Toolbox. Let's have a look and see how we can use that for our script.
1. In the Processing Toolbox click to open the history.
There you find what we did in the previous section. Try to read what's written after processing.run
.
It contains the name of the tool: native: rastersurfacevolume. It contains a dictionary with all the inputs from the dialogue. That means that we can copy this and replace parts of the dictionary in a PyQGIS script with a variable. Here we should iterate for different LEVEL values from the minimum to the maximum elevation in the DTM.
2. Click Close to close the History dialogue.
3. In the main menu choose Plugins | Python Console to open the Python Console.
4. In the Python Console click to open the editor.
5. Go to this GitHub page: https://github.com/jvdkwast/PyQGIS_Hydro/blob/master/scripts/StageVolume.py
6. Copy the Python code to the editor and save the script as StageVolume.py.
Read the comments to understand what happens in the code.
7. The only thing to change is to replace the projectPath
and inputRasterDEM
with your own names.
8. Save the script and click to run the script.
This is the result printed in the Python Console:
The script has also added a DEM layer and the StageVolume table to the Layers panel.
9. Click right on StageVolume and choose Open Attribute Table and inspect it.
We have created the Stage Volume Table with the Level field in meters and the VolAbsKm3 field containing the volumes in km3.
In the next section we'll create the Stage Volume Curve using the Data Plotly plugin.
Note that you can also add the StageVolumeTool from GitHub to the Processing Toolbox. The tool then has a dialogue. You can download the tool from here: https://github.com/jvdkwast/PyQGIS_Hydro/blob/master/scripts/StageVolumeTool.py
4. Create a Stage Volume Curve with the Data Plotly plugin
Now we have created the Stage Volume Table we can easily create the Stage Volume Curve with the Data Plotly plugin.
1. Install the Data Plotly plugin form the plugins repository.
2. Click to open the Data Plotly panel.
3. Make sure to choose the Scatter Plot as Plot type and StageVolume as the Layer. The X field is VolAbsKm3 and the Y field is Level.
4. Click
5. Uncheck Show legend. Set the Plot title to Stage Volume, keep the Legend title blank. Change the X label to Volume (km3) and Y label to Level (m).
6. Click
You can save the result as a picture using the button.
From the Stage Volume Curve we can see a sharp change at 86.4 m. That's approximately the elevation of the boundary of the pit.