5

I am building a model where I need to use an attribute value as parameter in the next tool. I include an illustration that will hopefully make the problem clearer.

enter image description here

So far I have been unable to extract the attribute value outputed by the Field Calculator tool and pass it as parameter of the Buffer tool. Does anyone know how to achive this?

2 Answers 2

5

The poblem here is that the Field calculator tool outputs a layer but the calculated attribute values are not exposed as a parameter to be used in subsquent steps of the model.

A way to solve this issue is to use the tool Basic Statistics for fields. This tool will take a numeric attribute and extract stastitcal aggregations that can be used as a parameter for the next tool:

enter image description here

So in this particular case, I simply had to add the Basic Statistics for fields tool after the Field calculator tool.

Thanks to Nyall Dawnson from North Road for the hint!

2

If you use the field calculator, you have new variables available if you use Pre-calculated Value for the input. Best see the screenshot added: for the parameter you want to set the attribute value outputed by the Field Calculator tool, choose Pre-calculated Value and than open the expression editor. You have several context-sensitive variables available like [algorithm_name]_OUTPUT, in my case: Feldrechner_OUTPUT:

C:\Users\DU\Desktop\alma.png

7
  • 1
    In some cases it is also necessary to set the fieldcalculator as dependency in the buffer tool because a variable is used
    – MrXsquared
    Mar 26, 2021 at 17:36
  • 1
    Thank you @Babel. I tried that but it does not work. I also tried variants like enclosing the variable name in single and double quotes but still no success.
    – Lisdengard
    Mar 27, 2021 at 10:02
  • Can you share your project/model?
    – Babel
    Mar 27, 2021 at 10:38
  • @Babel it seems the *_OUTPUT variable refers to the whole layer and cant be used to refer to a value within the attribute table, which is what I need. I am including a model case you want to look at it again: drive.google.com/file/d/1f3jXuL2hoQgcz7Vr1ewBkkyY1uW5Wbn7/…
    – Lisdengard
    Mar 31, 2021 at 11:14
  • you can get a feature by id using field calculator... or use some aggregate funcion tu do get a aggregate value from a specified column. Because the layer has 1 feature only get it! Mar 31, 2021 at 13:18

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.