Qgis Map Design

0 views
Skip to first unread message

Kayleen Dauteuil

unread,
Aug 5, 2024, 3:52:16 AM8/5/24
to adadrisup
Themodel designer allows you to create complex models usinga simple and easy-to-use interface.When working with a GIS, most analysis operations are notisolated, rather part of a chain of operations.Using the model designer, that chain of operations can be wrappedinto a single process, making it convenient to execute later with adifferent set of inputs.No matter how many steps and different algorithms it involves, amodel is executed as a single algorithm, saving time and effort.

Variables: Models can contain dedicated variables that are unique and only available to them.These variables can be accessed by any expression used within the model.They are useful to control algorithms within a model and control multipleaspects of the model by changing a single variable.The variables can be viewed and modified in the Variables panel.


Definition of necessary inputs.These inputs will be added to the parameters window, so the usercan set their values when executing the model.The model itself is an algorithm, so the parameters window isgenerated automatically as for all algorithmsavailable in the Processing framework.


Definition of the workflow.Using the input data of the model, the workflow is defined byadding algorithms and selecting how they use the defined inputsor the outputs generated by other algorithms in the model.


The first step is to define the inputs for the model.They are found in the Inputs panel on the left side of the modeler window.Hovering with the mouse over the inputs will show a tooltip with additional information.For a full list of available parameters in modeler and their correspondance for scripting,please read Input and output types for Processing Algorithms.


When double-clicking on an element, a dialog is shown that letsyou define its characteristics.Depending on the parameter, the dialog will contain at least oneelement (the description, which is what the user will see whenexecuting the model).For example, when adding a numerical value, as can be seen in the next figure,in addition to the description of the parameter, you have to set adefault value and the range of valid values.


You can define your input as mandatory for your model by checking the Mandatory option and by checking the Advancedcheckbox you can set the input to be within the Advanced section. This isparticularly useful when the model has many parameters and some of them are nottrivial, but you still want to choose them.


You can also add inputs by dragging the input type from the list anddropping it at the position where you want it in the modeler canvas. If you wantto change a parameter of an existing input, just double click on it, and thesame dialog will pop up.


In the following example we will add two inputs and two algorithms. The aim ofthe model is to copy the elevation values from a DEM raster layer to a line layerusing the Drape algorithm, and then calculate the total ascent of the linelayer using the Climb Along Line algorithm.


To add an algorithm to a model, double-click on its name or drag and drop it, just like for inputs.As for the inputs you can change the description of the algorithm and add a comment.When adding an algorithm, an execution dialog will appear, with a content similarto the one found in the execution panel that is shown when executing the algorithm from the toolbox.The following picture shows both the Drape (set Z value from raster)and the Climb along line algorithm dialogs.


Pre-calculated Value: opens the Expression Builder dialogand lets you define an expression to fill the parameter.Model inputs together with some other layer statistics are available as variablesand are listed at the top of the Search dialog of the Expression Builder.The expression is evaluated once before the child algorithm is executedand used during the execution of that algorithm.


You will also find an additional parameter named Dependenciesthat is not available when calling the algorithm from the toolbox.This parameter allows you to define the order in which algorithms are executed,by explicitly defining one algorithm as a parent of the current one.This will force the parent algorithm to be executed before the current one.


When you use the output of a previous algorithm as the input of youralgorithm, that implicitly sets the previous algorithm as parent of thecurrent one (and places the corresponding arrow in the modeler canvas).However, in some cases an algorithm might depend on another one even ifit does not use any output object from it (for instance, an algorithmthat executes a SQL sentence on a PostGIS database and another one thatimports a layer into that same database).In that case, just select the previous algorithm in theDependencies parameter and they will be executed in the correctorder.


Once all the parameters have been assigned valid values, click onOK and the algorithm will be added to the canvas.It will be linked to the elements in the canvas (algorithms or inputs)that provide objects that are used as inputs for the algorithm.


Links between elements are updated automatically and you can see a + buttonat the top and at the bottom of each algorithm. Clicking the button will listall the inputs and outputs of the algorithm so you can have a quick overview.


You might want to change the order of the inputs and how they are listed in themain model dialog. At the bottom of the Input panel you will find theReorder Model Inputs... button and by clicking on it a new dialog pops upallowing you to change the order of the inputs:


You can run your algorithm any time by clicking on the Run model button.When using the editor to execute a model, any non-default values will besaved in the inputs. This means that executing the model at a later time fromthe editor will have the dialog prefilled with those values on any subsequent run.


On the right-hand side, you will see a simple HTML page, created usingthe description of the input parameters and outputs of the algorithm,along with some additional items like a general description of themodel or its author. Also, there is an Example section where you caninput your own custom examples to help explain the usage of the model.The first time you open the help editor, all these descriptions areempty, but you can edit them using the elements on the left-hand sideof the dialog.Select an element on the upper part and then write its description inthe text box below.


Use the Save model button to save the current model and theOpen Model button to open a previously saved model.Models are saved with the .model3 extension.If the model has already been saved from the modeler window,you will not be prompted for a filename.Since there is already a file associated with the model, that filewill be used for subsequent saves.


Models saved in the models folder (the default folder when youare prompted for a filename to save the model) will appear in thetoolbox in the corresponding branch.When the toolbox is invoked, it searches the models folder forfiles with the .model3 extension and loads the models theycontain.Since a model is itself an algorithm, it can be added to the toolboxjust like any other algorithm.


Models loaded from the models folder appear not only in thetoolbox, but also in the algorithms tree in the Algorithmstab of the modeler window.That means that you can incorporate a model as a part of a bigger model,just like other algorithms.


As we will see in a later chapter, Processing algorithms can be calledfrom the QGIS Python console, and new Processing algorithms can becreated using Python.A quick way to create such a Python script is to create a model andthen export it as a Python file.


Selecting the Remove option will cause the selectedalgorithm to be removed.An algorithm can be removed only if there are no other algorithmsdepending on it.That is, if no output from the algorithm is used in a different one asinput.If you try to remove an algorithm that has others depending on it, awarning message like the one you can see below will be shown:


A model can be run partially by deactivating some of its algorithms.To do it, select the Deactivate option in the context menuthat appears when right-clicking on an algorithm element.The selected algorithm, and all the ones in the model that depend on itwill be displayed in grey and will not be executed as part of the model.


I am just trying understand how qgis and designer work together. From Nathan W's excellent posts I know how to create a user form and how to hook it to a qgis layer and also how to add validation code. My questions here are pretty naive but the stuff that everyone knows is precisely the stuff that one can't find in print:


designer.exe is installed into bin\ folder for OSGeo4w install however it doesn't seem the weekly builds include this yet. Shouldn't be too hard to add into the nightly, weekly packages. NOTE: If you want to download it yourself to install into your QGIS install. Download the following file -devel/qt4-devel-4.7.1-1.tar.bz2 and copy the apps, bin, include, lib folders inside into the root of your QGIS install.


Many data collection tasks are non-spatial, for example adding in a price list for road signs. The GIS can record which signs need replacing but the price list is needed to provide a cost estimate. Is there anyway of triggering the display of forms for non-spatial data tables?


I try to add some path in Qt Designer preferences (template paths) to /Applications/QGIS3.10.app/Contents/Frameworks/QtDesigner.framework/ and several paths within. Similar in the Qt Creator preferences (Designer > model paths).


Go to Application and "show package content" of QGIS package. You can open the shipped designer executable in /Applications/QGIS-LTR.app/Contents/MacOS/bin/ and double click "designer" (running this from the command line might not work). You should have all the widgets in the widget box


I have a general map of the Mediterranean Sea, showing all the countries I've considered in a study, with watersheds etc. I've tried to make it look nice, but I think it could do with a bit of extra design. All the features in the map are contained in seperate shapefiles (countries, watersheds etc).

3a8082e126
Reply all
Reply to author
Forward
0 new messages