I have a question about my model which is quite complex.

I have two types of line INPUT and the model will not be executed unless one of the line INPUT is empty. The problem is with a tool 'Snap points to lines' (logically - because there are no lines and points neither).

The question is, if there is some way with Graphical modeler to use a condition like

IF one of the line INPUT is empty 
THEN 'freeze' this branch of model, but continue with the second line INPUT 

I guess the best way is to turn the model into a script and here I can manage better the conditions. But I am not really PRO in Python so anybody can give me a hand?


  • Can you share some insight on why you use the tool, if there's no input for it? – Erik Jan 4 at 10:38
  • 1
    In graphical modeler, no, I once made a feature request for this: github.com/qgis/QGIS/issues/34804 so maybe some day... – MrXsquared Jan 4 at 10:46
  • @Erik - Ok the model is for pre-processing some data for electric infrastructure. In general there are 2 types of cables - underground and aérial. So the model prepare the data for processing over certain areas - but it works just for the areas where the two types of cables ( aérial and underground) are present. If not the model will give an error that one of the type of cable is empty. My aime is to make this model working even for the cases where only one type of cable is present. – Filip Strzinek Jan 4 at 11:04
  • @MrXsquared ok thank you – Filip Strzinek Jan 4 at 11:05
  • You could run the model separately for both layers, if both are present, or you could merge the layers before running (which then later might require some select by expression)? – Erik Jan 4 at 11:16

There is a new feature if you use QGIS 3.14 or higher - see visual changelog: New modeler algorithm for creating conditional branches:

A key feature introduced in QGIS 3.14 was the ability for models to have a conditional branch.

See here for details: https://courses.spatialthoughts.com/advanced-qgis.html#conditional-branching

So you should think about updating your QGIS version to the current QGIS 3.16, as this will also be the new Long Term Release.

For older versions, think if you could not add a QGIS expression to define inputs in such a was as to achieve what you want.


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.