[GIS] Vector Fields as Input Variable in Field Calculator

field-calculatorqgisqgis-3qgis-modeler

I’m working with QGIS 3.2 Bonn and I try to build a workflow in the graphic modeler. The model aims to build variable buffers depending on values from two attribute fields of an input vector layer. For calculating the distances for the dynamic buffers I use the field calculator and the input fields to the field calculator are addressed by their distinct names.

This only works as long as the attribute fields of the input layer always have the same names, so I wanted to modify the model for making it more flexible to other input vector layers with different field names. For this I tried to use the Vector-Field variable as input to the field calculator. In the Variable distance buffer tool, I managed to use one Vector-Field as input variable, but with the field calculator I haven't been succesfull yet.

Is it possible to use Vector Field as input in the modeler, or do I have to write a script for that?

Would be really glad if you could help me.

(I also searched in gis-stackexchange and the net but couldn’t find an answer to this for QGIS3.x.
I found only other questions with similar problems but without any solution:
Graphical modeler in QGIS 3.0.3 – Access Vector Field in Calculator
or questions refering to QGIS2.x:
How to link Number value with Field calculator in QGIS Modeler ?
)

An extract of my model with the part I don't get worked:

enter image description here

Here a screenshot of the field calculator and my idea of how to use it:

enter image description here

Best Answer

Is it possible to use Vector Field as input in the modeler, or do I have to write a script for that?

No, it is not possible. I have tried everything* and you simply cannot make the Field Calculator aware of the Vector Fields you choose.

* I tried, for example, to join the Input Vector Layer with itself to have a clou about the Input Fields (using a prefix). Turns out that I cannot search all fields of a Layer to find out if the specific prefix is contained in the Field name.

Related Question