Automating analysis tasks using the graphical modeler
Most analysis tasks involve using several algorithms. Repeating the same analysis with a different dataset or different input parameters requires using them one by one, making this task tedious and error-prone. You can automate analysis workflows using the Processing graphical modeler, which allows you to define a workflow graphically and wrap it in a single algorithm. This recipe introduces the main ideas about the modeler and creates a simple model as an example.
No special preparation is needed in QGIS for this recipe, but make sure that you have read the previous recipe about computing a topographic index. This recipe will create a model based on the workflow in that recipe, so it is important that you understand it.
- Open the graphical modeler by navigating to Processing | Graphical modeler:
- Double-click on the Raster Layer item to add a raster input. In the dialog that will appear to define the input, name it
DEM and set it as mandatory: - Click on OK to add the input to the canvas:
- Move to the Algorithms tab. Double-click on the Slope, aspect, curvature algorithm and set the algorithm definition, as shown in the following screenshot:
- Close the dialog by clicking on the OK button. This will be added to the modeler canvas, as follows:
- Add the Catchment area algorithm to the model by double-clicking on it in the algorithm list and filling in the dialog, as shown in the following screenshot:
- Finally, add the Topographic wetness index algorithm, defining it as shown in the following screenshot:
- The final model should look like the following screenshot:
- Enter a name and a group to identify the model and save it by clicking on the Save button. Do not change the save location folder, because Processing will only look for it in the default location, you can however change the name of the model. Close the modeler dialog. If you now go to the Processing Toolbox option, you will find a new algorithm in the Models section, which corresponds to the workflow that you have just defined:
The model automates the workflow and wraps all the steps into a single one.
By saving the model in the models folder, Processing will see this when updating the toolbox and will include it along with the rest of algorithms so that it can be executed normally.