In this tutorial, we will address the automation processing chains with QGIS processing modeller.
We will see how to set, edit, document and run a template. You will learn how to add data input and processing algorithms in a model. We will, also, discuss how to run the models iteratively as well as how to fit them together in others, and how to perform the models in batch mode.
Firstly, we will introduce the modeller and explore the various types of inputs and algorithms available for the models. Then, we will discuss, using examples step by step, how to develop a model that can be added to the processing toolbox.
The topics that we will cover in this tutorial are:
Chapter 1: Introduction – Opening the graph modeller, configure the modeller and name a model .
Chapter 2: The input data a model .
Chapter 3: The processing algorithms for a model
Chapter 4: Run , Edit , Document, and Store a Template
Chapter 5: Iteration and nesting of models . Export as a Python script
Chapter 1: An introduction to the graphic modeller
When you perform a spatial analysis, usually a series of operations are included. The result of one operation is used as an entry for the following operation. The final result concludes all this series of operations. In using the graphic modeller, you can combine these different steps in a single process. The interface of the graphic modeller allows you to visually define the data as input, the output data and the processing algorithms.
The entire analysis is, therefore, ready to be used, as a personalized tool, in the processing toolbox.
The personalized tool looks like other tools in the processing toolbox. You run it by double-clicking, a setting window opens , and after the identification of the input data layers and the wished names for the results, the entire analysis will take place in one step .
A major advantage of this approach is that the executed analytical work can be modified and run again. This allows seeing or understanding how changes in thresholds or values in the input data affect the results of an analysis.
If you perform an analysis for the selection of sites, you use many criteria through classifications according to specific thresholds for each criterion (distance, cost, etc.). If you ask at the end of the analysis, which would be the result if changing one of the thresholds, if you have performed the analysis manually step by step, you will have to redo all the steps. If, on the other hand, you have performed the analysis using a model, you will only have to modify the value of the threshold concerned and to re-execute the model .
Another advantage is that the model could be reused in others territories, simply changing the input data.
How to open the graphic modeller The graphic modeller can be opened through the QGIS interface using one of the two following options:
• By clicking on GraphicModeller from the menu Treatment
• By activating the panel Boxprocessingtools and in Models->Tools click Createa newtemplate
The process modeller window opens . On the left side of the window, there are two tabs: input and algorithms. They are used to add these two types of elements in the window graph of the modeller that occupies the rest of the window.
How to set up the modeller and give a name to our model Before starting a model, it is advisable to set up the modeller. The models are saved as files in JSON format with the extension .model . When you save a template, QGIS gives you the option to save the file in the templatefolder. You can define the location of the models folder by accessing the menu Treatment|options in QGIS. In the section Models of the setting options window, you can specify the location of the templates folder. Double- click on the default folder path and the button Browse ([…]) is displayed, and allows you to select another location:
To illustrate the basics of the modeller graph use we will employ a simple example that identifies the oyster plots located around the oysters establishments. There will be three entries and two algorithms. Firstly, we will give a name to our model as well as to the group. For this example, as shown in following screenshot we have opened the modeler graphicand named the model riparianplots and the group of models Oystercadastre .
This is the group and the name with which the model will appear in the setting toolbox.
Then, we click the Save button . The dialog box SaveTemplate opens, by default, in the folder models. Here you must choose a name for the file .model. We will call it riparianplots.model.
The model and the group name have to be defined before the model is recorded . If the models are registered in the default templates folder (..users / .qgis2 / processing / models), they will appear as layout tools in the panel of the processing toolbox (it will appear in this group in the processing toolbox).
The model appears with the name that was entered in the graphic modeller, as opposed to the one that was recorded in the disc.
The models can be registered outside the default template folder, but in this case will not appear in the panel of the setting toolkit.