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' ...
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.
You should include your DEM as an input within that model. I have reproduce your model and just add that entry, and it worked.
Here is the image of the model:
Here is a final screenshot showing the result:
Here you can get the model, the project and the layers I have used. Hope it works for you. Link to drive.
By the way, I did this in QGIS 3.8
To create a plugin from a model, use the "Plugin Builder" plugin.
By following THIS tutorial, you can build a basic structure.
On the third screen for plug-in creation, define the template as Process Provider. The model conversion is easier in this mode.
You will not need to use QT Creator or compile.bat described in the above link tutorial.
After you ...
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, ...
This is not possible, there is no converter for this because in the script it is possible to perform functions like IF, CASE and LOOP that do not exist in the modeler logic.
For example: leave an empty entry and the process still works perfectly.This is only possible with a script.
QGIS Processing algorithms can be thread-safe or not. According to the docs, the latter are :
[...] algorithms which manipulate the current project, layer selections, or with external dependencies which are not thread-safe.
You can run the following code snippet in a QGIS Python console (Ctrl+Alt+P) to obtain a list of QGIS Processing ...
To use a model to join one CSV file and one shapefile without adding the CSV file (Excel file) in the map, you can create a model using two Vector layer inputs.
The CSV (Excel file) file is added creating a Vector Layer with this parameters:
The second input will be your shapefile added as Vector layer.
This is the result:
When you run the model, ...
The Networks plugin for QGIS has a tool to create or update an existing field, which can be used in a model or run in batch processing.
In the following example, the model updates the "azimuth" field with a formula. A temporary or final layer is not created, the existing one is simply updated.
I am not sure how did you rotate the polygon grid, but it seems you have used Rotate tool from Processing toolbox. If so, you need to specify the Rotation anchor [x,y], which enables you to select the rotation position directly from the map canvas, as you can see below:
Using Rotate tool:
The Rotation anchor [x,y] was selected at the ...
Good question. It is not obvious, but you need to copy your script algorithms to a specific folder to make your standalone script able to run them.
You can easily see where your script algorithms should be located by adding a couple of lines to your standalone script:
from processing.script import ScriptUtils
print("Folder for script algorithms:", ...
Use the Field Calculator to create a new field, "OWNER1", with data type string(text), and the same field length as the "OWNER" field.
Use this expression:
If( "OWNERNO" = 1, "OWNER", NULL)
Repeat the operation to create a field for each value in the "OWNERNO" field, changing the "OWNERNO" value in the expression each time.
Create the field "OWNER1" ...
In the model environment, some variables are created for each input parameter, which can be used by algorithms.
The name of those variables is automatically assigned from the description of the parameter when it is created. For instance, in this model:
New variables are being created with the names of the inputs, converted to lowercase and removed ...
Found it.. Go to Processing menu- Toolbox - Project models - right click and Edit model: (This does not seem to work though for a Project saved in QGIS 3.10 that is opened in 3.12, have to save as model3-file in 3.10 then open file in 3.12):
To add to your model the two required tasks, you must use the Algorithms Field Calculator and Set Style for Vector Layer.
This is how your model should appear:
Using the Field Calculator algorithm you can create a new field using an expression ($length in your case).
This is how the algorithm should be compilated:
Now you can add to the output of ...
Matching the Layer Styles
Load all the layers into a single project.
Optional: In the layer panel, organize the layers into groups based on which map they belong on. This is just to help you keep track of which layers go in which map. If you can easily tell where each layer belongs based on the layer name, skip this step.
You can select a layer in the ...
I think you can do that just with the great internal tool from QGIS3 and without any knowledge of python. All within the graphical interface. You can access to the importing format (extension) by clicking in the '...' in the output element. Here you have the complete video with the process (I can't even upload here the complete gif...).
Here are some ...
Your expression needs to be in a string format excluding input parameters.
For example, if you want to reference existing fields inside your modeler without adding an input parameter:
'array_find( array_sort( array_agg("field")), "field")'
But if you want to include an input parameter which references a field:
'array_find( array_sort( array_agg(' || @...
We start with single-part line vector layers: 'Input' and 'Lines'.
'Input' layer contain countour lines as features.
'Lines' layer contain some dumb lines as features, wich we will use to rotulate the features of 'Input' layer.
Both layers are GeoPackage and cointain one "fid" field, autocompleted.
We need to know what features of the 'Input' layer, ...
It's quite simple. In the modeler there must be a vector input, a Fields Mapper and a refactor field at least.
The refactor field will receive both files.
Set the Fields Mapper on Fields mapping box.
When you run, you can set the output file columns as you like, similar to MrXsquared's response, but the fields are not fixed, they can be redefined on each ...
It is not yet the ultimate solution in terms of using entirely a Virtual Layer. However, it is possible to overcome the issue of creating offset for the starting/ending points. And it works well within a Processing Modeller, see Phase 3.
Tested on QGIS 3.4
The full solution will probably include something as ST_Line_Interpolate_Point() and using ...
I believe it is not possible to delete features in the modeler, in this case use the extract by expression and put an expression that generates the opposite result of your current selection.
This will result in a layer with the features that match the expression you entered.
Therefore unwanted features were not deleted but ignored.
It requires a string list as input:
But if you're going to use it through the modeler, might I suggest using the Vector field input parameter which can be set to accept multiple fields. You can connect this parameter to the "Add autoincremental field" tool. Then when you run the model, you can simply choose the fields you want ...
Thanks to the comment by @GISGUILD:
Andrea, I have kind of similiar question with an answer for you. Does this help you? You are looking for a prefix. Batch add column to layers and add layer prefix in PyQGIS
I was able to solve my problem. At first, I modified the python script generated by the QGIS Modeler, adapting the solution linked by @GISGUILD. ...
In QGIS 3.8 you can do more complicated file naming in the bulk processor using calculate by expression. Rather than hitting the ... you can do the Autofill... drop down and select calculate by expression and in the expression choose the field with your original file and add the text you want before or after the field.
For example this expression adds ...
This is currently not possible. It is conceivable that such a feature can work by inferring the Input Type from the layer and adding appropriate input in the modeler. However there are cases where this is not optimal. For example, a vector layer can be part of 'Vector Layer' or 'Map Layer' or 'Multiple Input' type. So it may end up confusing some users if a ...
I tried to create a string input, with the default value /home/etienne/test.gpkg|layername=layer4, I can use this input as Input layer, but yes I can't select it for Mask layer. This looks like a bug to me.
What I could do is to use the string concatenation algorithm. Use a string input with the geopackage path and append the name of the layer you would ...
You can use layer_property function with @layer keyword. @layer returns input layer itself.
Normally, the first parameter of layer_property is a string representing layer name or ID. But in Modeler case, since you cannot know the name of layer passed as input, it's useless. Therefore, the other choice is to use @layer keyword instead of layer name.