2

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

  • Did you see this answer? gis.stackexchange.com/a/177429/122597 – Stefan Sep 8 '18 at 20:39
  • Hi Stefan, yes, I saw this post. But it's concerning QGIS 2.x and I cannot use the script in QGIS 3.x Apart from that, at the moment I would prefer a pure modeler solution as I'm totally new to scripting and pyQGIS3 – L.Blanc Sep 8 '18 at 20:43
0

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 prefi). Turns out that I cannot search all fields of a Layer to find out if the specific prefix is contained in the Field name.

  • Hi Stefan, thanks for your answer. Do you know if the advanced python field calculator is able to handle input fields? Or do you think its the same problem with it. I have already tried with the advanced python field calculator but the syntax there is also not easy to unterstand for me. – L.Blanc Sep 9 '18 at 11:21
  • There are some hints on the syntax here: anitagraser.com/2013/04/20/advanced-python-field-calculator Unfortunately I don't think that you can target fields that are not known before runtime. – Stefan Sep 9 '18 at 15:16
  • I've read that article from anita graser, too. But I think it concerns the advanced python calculator outside of the graphic modeler. At least I couldn't rebuild the example in the modeler. I guess I have to learn python/pyQGIS and start scripting. Unfortunately - that seems to be more advanced than in QGIS2. – L.Blanc Sep 9 '18 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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