Create a Graphical Model for the HAND Algorithm
Site: | OpenCourseWare for GIS |
Course: | FOSS4G 2022 Workshop Hydrological analysis with PCRaster in QGIS and Python |
Book: | Create a Graphical Model for the HAND Algorithm |
Printed by: | Guest user |
Date: | Wednesday, 4 December 2024, 11:49 AM |
1. Introduction
In this tutorial we're going to make a graphical model in QGIS to calculate the Height Above Nearest Drainage (HAND) with the PCRaster Tools.
We'll use the data from the previous tutorial.
Reference :
Renno, C. D., Nobre, A. D., Cuartas, L. A., Soares, J. V., Hodnett, M.
G., Tomasella, J., & Waterloo, M. J. (2008). HAND, a new terrain
descriptor using SRTM-DEM: Mapping terra-firme rainforest environments
in Amazonia. Remote Sensing of Environment, 112(9), 3469-3481.
2. Setting the Model Properties
In this section we'll setup a graphical model in the QGIS Model Designer.
1. In the Processing Toolbox panel, click Models icon and choose Create New Model... from the drop-down menu.
2. Maximize the new window of the Model Designer.
3. Let's first enter the Name and Group in the Model Properties section. Give it the Name Height Above Nearest Drainage. For Group write Hydrology. The model can then be found in the Processing Toolbox under Models | Hydrology | Height Above Nearest Drainage.
Let's save the model. You can save models in your QGIS profile or in your project. If you save the model in your profile, it will be available for all projects that you work on from that profile. In this case you use the Save model as icon to save a .model3 file under \profilename\processing\models . If you only want to use the model in this project use the Save model in project icon.
4. Choose one of the options to save your model.
3. Define the Input Parameters
In the upper left panel of the Model Designer you can see the Inputs.
For our model we need a drainage raster and a DEM.
1. In the Inputs panel scroll down and double-click on Raster Layer.
2. In the Raster Layer Parameter Definition popup type Drainage (boolean) at Description and keep Mandatory checked.
Now you have defined that in the graphical user interface the user sees that a boolean drainage raster needs to be selected as input.
3. Click OK to add the input to the Model Designer.
4. Repeat this to add the DEM input raster to the Model Designer.
Next, we're going to use these inputs for the calculations.
4. Add Processing Algorithms to the Graphical Model
Now we can add algorithms for our calculations.
First we need to assign a unique value to each cell of the drainage raster in order to derive the catchments of each cell of the drainage.
1. In the upper left panel of the Model Designer click on the Algorithms tab.
Here you'll recognise most of the tools that are available in the Processing Toolbox. Also the tools from the Processing Provider plugins are included, which means that you can create models which mix algorithms from different processing providers.
2. Use the search box to find the PCRaster uniqueid algorithm.
3. Double-click on the uniqueid algorithm.
4. In the uniqueid dialog:
- type at Description: assign unique values to drainage cells.
- change Using model input to Drainage (boolean)
- Keep the Output unique id raster field empty. This field is only used if we want the (intermediate) output to be written to a file and that the user can choose the output file in the dialog. In this case we don't need that.
- Change the Description to Convert to nominal
- Use the drop-down menu under Input raster layer to choose Algorithm Output.
Note that we only have one output, so that's automatically selected. If you have multiple algorithm outputs you can choose it at Using algorithm output. - Change the Output data type to Nominal.
- We're not saving the intermediate result, so we leave the Output raster layer field empty.
- At description type: calculate flow direction
- Keep the rest as default
- change the LDD layer to the output of calculate flow direction.
- change the Outlet layer to output of convert to nominal.
- For Description type: calculate lowest elevation per catchment.
- For Class raster layer choose the output of calculate catchments.
- For Input ordinal or scalar raster layer choose the DEM layer.
- Change the Description to: calculate HAND
- Input layer A should be defined as the DEM with raster band 1 (we only have single-band rasters here).
- Input layer B should be defined as the output of calculate the lowest elevation per catchment with band 1.
- At Calculation in gdalnumeric syntax type:
A-B
Where A and B refer to the layers defined above. - Output raster type should be set to Float32, because it's continuous data
- At Calculated type Output HAND raster, because now we'll write the final result to disk.
5. Add a Help Text
It's good practice to add a help text for the end user of your model
1. Click Edit model help icon in the toolbar of the Model Designer.
2. Under Select element to edit the Element description of each element.
3. Click OK.
Now we're ready to test the model.
6. Run the Model
You can run the model from the model designer by clicking or you can run the model from the Processing Toolbox. where it now appears under Models | Hydrology | Height Above Nearest Drainage.
1. Run the model with data from the previous tutorial.
2. Check and style the result.