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

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.
    – Gabriel
    Aug 18 at 18:21
  • Here the info about conditional branch, available since QGIS 3.14: gis.stackexchange.com/a/383419/88814
    – Babel
    Aug 18 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 Aug 25 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? Aug 25 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
    – Babel
    Aug 25 at 15:49

0

Your Answer

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

Browse other questions tagged or ask your own question.