1

I wanted to make a small if/else custom script inside the QGIS Modeler. I want the "Centroids" algorithm to be applied when the "L" field (created earlier in the "trees" layer) is set to 0, for any other value of the "L" field, the originally intended algorithm should be applied (shown in orange in the screenshot). The question is similar to this one QGIS Modeler if/else condition, custom script for Modeler but it's not clear to me how to reference the layer field. This is my first time trying to insert code into my model, so it's not quite clear yet.in the screenshot, only the part of the model necessary for work

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Aug 18, 2022 at 18:02
6
  • 1
    What version of QGIS are you using? There is, since a few versions back, a modeler tool called Conditional Branch. It might be enough for what you try to achieve. Commented Aug 18, 2022 at 18:21
  • Here the info about conditional branch, available since QGIS 3.14: gis.stackexchange.com/a/383419/88814 Commented Aug 18, 2022 at 19:29
  • Yes, my version has such a tool, but the problem is that the model will be used on other computers where the version of QGIS is lower than the one in which this tool appeared. I wanted to make the model not so demanding on the version @Gabriel Commented Aug 25, 2022 at 15:23
  • @Babel thx, but will this tool work if the model is run on a version of QGIS where there is no such tool? Commented Aug 25, 2022 at 15:25
  • No, in this case, it will not run. Maybe try to export the model as Python script - I don't know if it will run in this case. You must try it Commented Aug 25, 2022 at 15:49

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

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.