7.1. Automation theory#

Attention

🚧This part of the training platform is under ⚠️construction⚠️ and is not ready to be used in a training

7.1.1. Introduction into the QGIS Graphical Modeler#

The Graphical Modeler also known as the Model Builder allows users to create complex models using a visual interface. Most analysis tasks in a GIS are not isolated, but part of a chain of operations resulting in a series of inputs and outputs (e.g. clipping the area of interest, performing a spatial join and applying some table functions). Using the Graphical Modeler, this chain of operations can be combined into a single process, which can then be easily reproduced with a different set of inputs. Regardless of how many steps and different algorithms are involved in the analysis, a model is executed as a single algorithm, saving time and effort.

7.1.1.1. Graphical User Interface#

The Graphical Modeler can be accessed from the Processing menu Processing -> Graphical Modeler as shown in Fig. 7.1.

../../_images/en_open_graphical_modeler.png

Fig. 7.1 How to open the Graphical Modeler in QGIS#

This will open the following window, which contains everything we need to build a model.

../../_images/en_gui_graphical_modeler.PNG

Fig. 7.2 Screenshot of the Graphical Modeler window for QGIS version 3.28.4#

In the Graphical Modeler window we can see several icons and menus. Firstly, we will focus on the left window for the Inputs and Algorithms section. Inputs are all the input variables or layers for a model, such as a Vector Layer, Raster Layer, String, Boolean, Expression and many others. The Algorithms are all the tools that are used to process the input variables. In the processing chain, one algorithm/tool will return an output that will be used by another/the following tool until the final output is created.

7.1.1.2. Creating a model#

Creating a model involves two basic steps:

  1. Defining the necessary inputs. These inputs are added to the parameter window so the user can set their values when running the model.

  2. Defining the processing steps. The processing steps are defined by adding algorithms and selecting how they use the defined inputs or the outputs generated by other algorithms in the model.

7.1.1.2.1. Building a model to buffer road infrastructure#

We will build our first simple model by buffering road segments. This process is based on a vector layer containing the road data and the buffer algorithm.

7.1.1.2.2. Selection of inputs#

Select the Inputs tab from the left window and then select the Vector Layer by either double-clicking or dragging and dropping it onto the model canvas (Fig. 7.3). This will open the input Parameter Definition window (Fig. 7.4). In this window we can customize some vector input parameters such as Description (the name that the user will see when executing the model), Geometry type (Point, Line, Polygon) and can also define your input as mandatory for your model by ticking the Mandatory box. It is also possible to select the Advanced checkbox to set the input to be within the Advanced section. This is particularly useful when the model has many parameters and some of them are not trivial, but you still want to be able to select them.

../../_images/en_vector_layer_modeler.PNG

Fig. 7.3 Vector Layer as input#

../../_images/en_input_vector_modeler.PNG

Fig. 7.4 Vector Layer Parameter Definition#

7.1.1.2.3. Selecting the Algorithms#

Now, select the Algorithms tab on the left. These are the same algorithms as in the processing toolbox. If you know where an algorithm is, you can select it directly. Otherwise, you can search for it using the search toolbar. For this example we will search for the Buffer algorithm as shown in Fig. 7.5. Add it to the model canvas.

../../_images/en_model_buffer.PNG

Fig. 7.5 Selection of Buffer algorithm#

When you double-click on it, the Buffer Algorithm window appears. The algorithm window looks a bit different than when using the algorithm outside the model builder. The main difference is that you have to specify the algorithm input as either being one of the model inputs you have defined or an output of another algorithm. By selecting the output of another algorithm, you can effectively chain multiple analysis steps into each other to create a complex workflow. In our case, we want to select the road infrastructure input as the input for the buffer algorithm. Next, we want to specify the buffer size. The units of measurements will be the same as for the project CRS. Enter 200,000. This will instruct the algorithm to create a buffer of 200 meters (or units of measurement).

Once you have added the

7.1.1.3. Tips and Tricks when working in the model designer#

7.1.1.4. Areas of application#