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
-
1What 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– Gabriel2022年08月18日 18:21:20 +00:00Commented Aug 18, 2022 at 18:21
-
Here the info about conditional branch, available since QGIS 3.14: gis.stackexchange.com/a/383419/88814Babel– Babel2022年08月18日 19:29:46 +00:00Commented 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 @GabrielKyBik RyBik– KyBik RyBik2022年08月25日 15:23:35 +00:00Commented 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?KyBik RyBik– KyBik RyBik2022年08月25日 15:25:48 +00:00Commented 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 itBabel– Babel2022年08月25日 15:49:59 +00:00Commented Aug 25, 2022 at 15:49