2

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?

asked Jun 10, 2022 at 13:02

1 Answer 1

2

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.

  1. Open the Model Designer and select a number input (I will call it Input Integer). Inputs enter image description here
  2. 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
  3. Now we add the field calculator and calculate a new field with @inputinteger expression. enter image description here
answered Jun 10, 2022 at 21:05
5
  • 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. Commented Jun 13, 2022 at 5:10
  • Ok, I update the answer. Commented Jun 13, 2022 at 22:40
  • 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. Commented Jun 16, 2022 at 5:16
  • 3.24.3-Tisler in Ubuntu 22.04 Commented 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. Commented Jun 26, 2022 at 5:03

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.