Adding algorithms to your model

Algorithms are added to the graphical modeler in the same way as inputs. Find the algorithm from the Algorithms tab, and either double-click on it or drag it onto the modeler canvas. You can search for tools as you would in the Processing Toolbox. Type the name into the search box at the top of the Algorithms tab:

Adding algorithms to your model

Here we see the Algorithms tab with buffer being used as the search term.

In the Algorithms tab, there is a special category named Modeler-only tools. The three tools—Calculator, Raster layer bounds, and Vector layer bounds—do not appear in the Processing Toolbox. They are tools that only make sense when they are used in the context of the graphical modeler:

Adding algorithms to your model

The Calculator tool is perhaps the most commonly used of the three tools. It allows you to perform arithmetic calculations on numeric outputs from other algorithms. For example, if you use one of the statistical output tools such as Raster layer statistics in your model or if you have numeric inputs, the associated numeric values will be available to the Calculator algorithm. The calculator lists the available numeric values within the model. They are labeled from a to x with the description to the right. Below this is a text box for entering a formula. For example, the formula given in the following screenshot divides the Canopy density value by the Owl Habitat Acres value and multiplies the result with the standard deviation from the Raster layer statistics algorithm. The output from the Calculator algorithm can be fed into other algorithms.

Adding algorithms to your model

The algorithm dialog will look very similar to how it would if you were running it from the Processing Toolbox. There are inputs, tool parameters, and outputs. However, there are some important differences because the graphical modeler is a self-contained universe of data inputs. The differences are as follows:

  • Input layers are limited to those that have been added to the model.
  • Output can be left blank if it is an intermediate result that will be used as an input for another algorithm. If the output is a layer that needs to be saved, enter the name of this layer in the text box. When naming an output layer, you won't actually need to provide an output filename. This will be done when the tool is run. Instead, you just need to enter the name of the layer (for example, stream buffer).
  • Numerical values or string-value parameters can be entered as numbers or strings. They can also be chosen from other inputs of the Number or String type.
  • The fields of an attribute table (or another standalone table) can be specified by typing the field name or by using the Table field input. These fields will be chosen when the model is run.
  • Parent algorithms is an additional parameter found only in tools that are run from the graphical modeler. It allows you to define the execution order of algorithms. Setting an algorithm as a parent forces the graphical modeler to execute this parent algorithm before the current algorithm can be run. When you set the output of one algorithm as the input for the next one, you automatically set the first algorithm as the parent. However, in complex models, there may be several branches, and it may be necessary for an operation in a separate branch of the model to be completed before another operation can run.
  • Again in this example, we will be buffering streams by 100 meters and then clipping trees by that buffer layer. The first algorithm that we will add is Fixed distance buffer. Double-click on the tool from the Algorithms tab and the tool dialog will open. The tool will be filled like the following screenshot. Notice that instead of setting an explicit buffer distance, the Buffer distance input is being used. Also, note that no output is named since this output will be considered as an intermediate dataset:
    Adding algorithms to your model

Next, we'll add the Clip tool to the model using the following parameters:

  • Set the Input layer field to Trees
  • Set the Clip layer field to 'Buffer' from algorithm 'Fixed distance buffer'
  • Type Riparian Trees under Clipped<OutputVector>
  • Finally, click on OK

The completed tool dialog is shown here:

Adding algorithms to your model

The final model looks like the following screenshot. The connecting lines show how elements are connected in the workflow. The input, output, and algorithm elements have different-colored boxes so that they can be distinguished. The algorithm boxes will also include an icon representing the source library. For example, the Fixed distance buffer and Clip tools are QGIS algorithms and have the Q icon within the element box:

Adding algorithms to your model
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset