The problem:
I have a model with several input parameters (e.g. input_holesize, input_threshold etc.). The model creates a polygon layer as its final output. I would like to save the parameters into the attribute table for each feature in order to make the results more transparent. I use QGIS 3.16.7 on a Windows 10 system.
Attempts of solution:
I added another field calculator operation as another algorithm to my model. I wanted to use the function parameter, which seems quite straightforward (function example given in the field calculator: parameter('BUFFER_SIZE') → 5.6
). I tried various variants (e.g. parameter('input_threshold')
as well as parameter(input_threshold)
and parameter("input_threshold")
and to_string(parameter('input_threshold'))
). For none of these functions the field calculator returns an error message, however, the output is allways an empty field.
Aparently I am using the wrong syntax, or the function is actually not what I need.
My question:
Does anyone know, how to write the input parameters of a model into the attribute table of the output layer?
1 Answer 1
The parameter
function is used to get input parameters of the current tool. So create an input in the model designer and then you can call it by @Description, Description being the name of the input.
- Open the Model Designer and select a number input (I will call it Input Integer). Inputs enter image description here
- Set the input that you defined befor as the input of the tool you want to run (lets say a buffer and the input integer will be the distance). enter image description here
- Now we add the field calculator and calculate a new field with
@inputinteger
expression. enter image description here
-
Thanks for the answer. Could you elaborate some more? I tried to call e.g. @input_threshold in the field calculator but still get an empty output.C.-F. Vintar– C.-F. Vintar2022年06月13日 05:10:22 +00:00Commented Jun 13, 2022 at 5:10
-
-
Thanks for the clarification. I do not have this parameter in my field calculator. Which version of QGIS do you use? I updated my question with my current version.C.-F. Vintar– C.-F. Vintar2022年06月16日 05:16:00 +00:00Commented Jun 16, 2022 at 5:16
-
3.24.3-Tisler in Ubuntu 22.04Mayo– Mayo2022年06月16日 13:33:46 +00:00Commented Jun 16, 2022 at 13:33
-
According to the changelog this is a new feature in Version 3.24 and not available so far in the LTR-Version 3.22.C.-F. Vintar– C.-F. Vintar2022年06月26日 05:03:46 +00:00Commented Jun 26, 2022 at 5:03