Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now
16

Sextante is a geoprocessing library that can be used from several GIS applications. I recommend you to use it from gvSIG as i think that it has the best integration. Sextante also allows (if you configure it properly) use algorithms from SAGA and GRASS. Here you can see a video that shows how the modeler works. Update: From March, qgis also has a Sextante ...


15

GRASS has a model builder that works pretty well (don't know how it compares to the Arc* one). Victor Olaya, the developer of Sextante is currently working on Sextante for QGIS. It's work-in-progress and not yet ready for production use so use with care. You can watch a short demonstration of the Sextante model builder here: http://www.youtube.com/watch?v=...


15

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


14

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 ...


13

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


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 ...


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() ...


9

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.


8

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.


7

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 ...


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 ...


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....


6

I think a custom script might be needed for this which allows you to set fixed layers and use these in your model without having to constantly specify them. You can create one from: Processing Toolbox > Scripts > Tools > Create new script And use something like the following: ##Example=name ##Listed_Building=output vector ##Building_Centre_Points=...


6

Just had a bit of a play with this. If you enter a decimal value for the default when setting up the parameter, you can use a decimal for the value when running the model.


6

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


5

I too have always wondered how to use the "File" parameter. Instead, remove the directory field and use the Vector layer as your input ("shp-File"): Save the model with your parameters for your field calculator. Then go back to the Processing Toolbox menu and right-click your model. There should be a "Execute as batch process" option: From the interface, ...


5

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=...


5

The Extract by attribute tool from the modeler accepts String inputs, not Number inputs. Here's a simple test which uses the following input parameters: Input - Table Field Layer - Vector layer Value - String (with default value of 80) Now when I run this, the default value will show up automatically: I have tested this on various field attributes (...


5

You could create a custom script in your model to clear the '/tmp' folder at the end of each run. There's numerous ways to delete files but I like to use shutil.rmtree which deletes all files/folders in a specified directory. To do this, go to Processing Toolbox > Scripts > Tools > Create new script and copy the following (adjust the path): import shutil ...


5

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 ...


5

QGIS modeler treats any tool as intermediate which does not save any output, unless otherwise stated. To force the model to export a result, you have to input a layer output name in the Tool row. If I want to export the above result as a layer, I input a value in the output as so: What this does is add a dialoge box whenyou run the tool that you can set ...


5

This is more of a workaround as I'm not sure if it's possible at the moment to allow a user to select from a range of string values. Instead, you could use booleans which would represent your formulae (these would be connected to a custom script which will contain your formulae). So that when a user clicks on a boolean from the modeler, the script will ...


5

You could use the Join attributes by location tool (which hopefully should in available in your modeler). If you select the Attribute summary option and choose Take summary of intersecting features, it will insert a Count field into your layer. If you don't want to calculate the sum, mean etc then just remove them so that the textbox is blank, that way you ...


5

Adding Save selected features should do the trick:


5

You should use the same syntax like in field calculator of QGIS (FC). From python there is a little hack you have to do. The working function in FC is: replace("from_field", '\\' , '/') From python, using QgsExpression, you will escape twice the backslash char, so the new function becomes: 'replace("' + Fromfield + '", \'\\\\\' ,\'/\')' Your code should ...


5

You could try creating a custom script which: Ensures all features are deselected. Selects the feature(s) matching your expression. Saves the selected feature(s) in a layer. You can create one from: Processing Toolbox > Scripts > Tools > Create new script Then use something like the following: ##Save_selected_features=name ##Input_Layer=vector #...


5

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 ...


5

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" ...


5

According to https://github.com/qgis/QGIS/pull/2396 it should be possible to have optional parameters in models and scripts. The script case is covered by Make an optional input parameter in QGIS Processing Algorithm Script. In your case, the first alg you're trying to run is outputs_SAGACONVERTPOLYGONLINEVERTICESTOPOINTS_1=processing.runalg ('saga:...


5

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 ...


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