16

If you are calculating a field of String type, this is the right syntax: CASE WHEN "VSt_K" = 'A' THEN '1' WHEN "VSt_K" = 'B' THEN '2' WHEN "VSt_K" = 'C' THEN '3' END Instead, if it's of Integer type: CASE WHEN "VSt_K" = 'A' THEN 1 WHEN "VSt_K" = 'B' THEN 2 WHEN "VSt_K" = 'C' THEN 3 END EDIT The syntax of the Advanced Python Field ...


15

Good news is that it's been fixed for QGIS 3.0.


14

Now you can access a model builder in QGIS from the: Processing menu -> Graphical modeler


14

Very nice use case for yet another handy QGIS feature: Layer actions! Here the steps to configure your layer action: Open your layer Properties dialog. Click on menu Actions. Click on the green cross to add an action. Fill the dialog inputs as indicated in the following picture. You can Copy & Paste this couple of lines of code into the 'Action Text' ...


12

The way I would set your task up would be to create a custom script which provides greater flexibility than the modeler but can still provide a similar interface to its users. You can create one from: Processing Toolbox > Scripts > Tools > Create new script Then copy/paste the script below and save it into C:/Users/You/.qgis2/processing/scripts. The ...


11

You can use is_selected() function in if statement to perform calculation on just selected features.


11

You need to separate them via semi-colons: field1;field2;field3


11

You can use expression within a model. For instance, my distance is in kilometers. But I want to do my buffer with meters. Next to the distance field in the buffer algorithm, you can choose an expression input. And then use the number input with a formula.


10

Create a new script from: Processing Toolbox > Scripts > Tools > Create new script Use something like the following: ##Example=name ##Layer=vector from qgis.core import QgsField from PyQt4.QtCore import QVariant layer = processing.getObject(Layer) idx = layer.fieldNameIndex('Source') if idx != -1: pass else: layer.startEditing() ...


10

Processing in QGIS 3 was refactored a lot and many algorithms were changed. So it is not possible to covert old models into new format. You need to recreate it. says Alexander Bruy, QGIS contributor, core developer and translation team lead, in this post.


10

I had done something similar with python. The script loops recursive through the directories starting from the startdir and then opens each geopackage and reads the gpkg_contents table - containing geometry type, extent, CRS, date and so on, the second query selects the number of features. The script works on the first featuretable in a geopackage only, may ...


9

As mentioned in my comment, a custom script may be the way to go in this situation. You can create one from: Processing Toolbox > Scripts > Tools > Create new script The following script sets the input parameters as optional along with an if/else statement depending on which parameter contains a layer. So if a layer was selected for BGREN, it will ...


9

This was intentionally disabled by commit 4f2a464 [processing] remove obsolete code and disable exporting models as script until we update it so support new scripts format @alexbruy alexbruy committed on 2 Feb So re-enabling it yourself won't be of any use as the output code won't be usable in QGIS 3x.


8

A little dig in the processing algorithms and you can find: Split vector layer This algorithm takes a vector layer and an attribute and generates a set of vector layers in an output folder. Each of the layers created in that folder contains all features from the input layer with the same value for the specified attribute. The number of files generated is ...


8

Yes, you can use "select by expression" tool and insert if(is_selected() is false,true,false) as expression. This will allow inverting your selection in graphical modeler. Result:


8

The geometric predicate input expects an index, starting from 0 as input as array or comma separated string. E.g. '1,3' or [1,3] for contains and touches. Since using numbers is not quite intuitive, I suggest to use an Enum-Input: As already mentioned, the important thing is the order of the items within this input. It has to be the same as it would it be, ...


7

Instead of using the Field Calculator tool, a possible workaround is to create a custom script which allows the user to choose an attribute field and update it with a value they enter. To do this, go to Processing Toolbox > Scripts > Tools > Create new script and copy the following: ##Update field by number=name ##Layer=vector ##Fields=Field Layer ##Number=...


7

You can create a model from the Processing Toolbox which allows you to automate a number of tasks. You can create one by going to the menubar: Processing > Graphical Modeler... From the Inputs tab (shown in the red box), you will need two Vector layer parameters (shown in the blue box) for both your line and polygon layers. Then from the Algorithms ...


7

You would be better off using 'Select by expression' instead of 'Select by attribute'. Your expression should be something like - "AREA" = maximum( "AREA" ). (Replace AREA in the expression with the name of the column). For example, the following screenshot shows how to select the polygon with the maximum value of the POP_EST field using 'Select by ...


7

I fear there is no simple way to convert geoprocessing models from QGIS 2 to 3. Simply converting it from json to xml can be done with services like http://www.utilities-online.info/xmltojson/ but the structure of the result is completely different between the two versions: Converted from QGIS 2 model json (example): <?xml version="1.0" encoding="UTF-8" ...


7

This workflow needs the csv-layer added into the layer panel before. QGIS 2.18 Workflow from Inputs you add a Table (Picture Nr 1. - 2.) add "Points layer from table" (Nr. 4) 2a. define x and y fields 2b. define output-file save and run model (Nr.5) The steps aren't simliar with the screenshot, but the order in general is the same. QGIS 3.2.1 Workflow ...


7

Inside a model fieldnames without any quotes separated by semicolon: field1;field2;field3


7

You need to use the Vector Features input parameter if you want to iterate over all or selected features: Now when you run the model, you can choose whether to run the model once on all or selected features and return a single output; or iterate over all or selected features and return an output per feature:


7

SAGA For the SAGA raster calculator, you can set the Formula option to read the value from your Number Input parameter: In the Formula option, set the drop-down menu to Pre-calculated Value. The first layer is defined by the string 'a'. So if you want to take the original values from the first raster layer and add the value from the Number Input parameter, ...


7

Create a New Model and add a Vector Layer Input. Restrict accepted geometries to Polygon. Add an Expression Input. The parent layer must be the vector layer input because the expression will be evaluated against that layer. Add an Extract by Expression algorithm. Select the vector layer and the expression from the model as inputs for the algorithm. ...


7

Yes, thats basically some simple stuff that has changed in 3.14. You are doing it correctly for older versions. Since 3.14 you first need to click on the "123" field just on the left and select "model input". Then you can choose your Model-Input-Layer from the dropdown menu.


7

There are several options I may refer you to "Field calculator": qgis:fieldcalculator Opens the field calculator. You can use all the supported expressions and functions. A new layer is created with the result of the expression. The field calculator is very useful when used in The graphical modeler. "Refactor fields": qgis:...


7

I'm on QGIS 3.18.2, array() works for me. Consider this model: You are on the right track with expression, in my case it looks like following the hint "Expected input: an array of layer paths, ...", strange that I couldn't get this to work with string concatenation either (like ... || ';' || ...)


6

If you want to pass a path in your model to save your shapefiles into instead of doing it manually, a custom script is probably the way to go. You can write a script to run the Extract by location tool and define the path of the output. Something like this perhaps: ##Extract_by_location=name ##Layer=vector ##Additional_layer=vector layer = processing....


Only top voted, non community-wiki answers of a minimum length are eligible