I have developed a processing model in QGIS 2.18 where all my inputs are optional and I need them to be truly optional. However, the model will not run unless I have all inputs present.

I have tried this model in both 2.18 and 3.0. I would prefer to use 3.0, but cannot figure out how to edit the python script. I think my problem is that it is not registering outputs as optional, but I'm not sure. Below is a sample of my code from the 2.18 model. I have also attached a screen capture of the start of the model in 3.0. I have been successful at running the models if all inputs are entered. I've tried recreating the model on two different computers, tried using QGIS 2.14 and searched the stackexchange/google etc.

##lines to points=name
##accesspoint=optional vector
##cableburied=optional vector
##ugspan=optional vector
##equipment=optional vector
##attachment=optional vector
##buildingfootprint=optional vector
##spliceclosure=optional vector
##buriedugspan=output vector
##ugspanvaccesspoint=output vector
##cableburiedv=output vector
##splicecable=output vector
##ugspanv=output vector
##ugspanaccess=output vector
##buildingcable=output vector
('saga:convertpolygonlineverticestopoints', cableburied,cableburiedv)
('saga:convertpolygonlineverticestopoints', ugspan,ugspanv)

1 Answer 1


According to https://github.com/qgis/QGIS/pull/2396 it should be possible to have optional parameters in models and scripts. The script case is covered by Make an optional input parameter in QGIS Processing Algorithm Script.

In your case, the first alg you're trying to run is

('saga:convertpolygonlineverticestopoints', cableburied,cableburiedv)

where cableburied is defined as optional further up.

I think the problem is that SAGA algorithms do not have any optional parameters. Instead, all parameters of saga:convertpolygonlineverticestopoints are mandatory.

The only way to use optional model parameters seems to be in combination with algorithms that expose optional parameters. For example, in QGIS 3, native:addautoincrementalfield has optional parameters:

enter image description here

From Python, this algorithm can be called with or without the optional parameters:

enter image description here

When building a model, the an optional input can be assigned to the optional values:

enter image description here

This is how it looks when the model is run:

enter image description here

  • That makes sense to what I am seeing. Is there a way to filter what algorithms use optional parameters or to adjust the script so it reads as optional outputs. Commented Apr 1, 2018 at 14:55
  • Could I use a boolean to build a python script that says if the parameter isn't inputed then that line of processing stops? Commented Apr 1, 2018 at 16:58
  • Could you elaborate on the reason for trying to build one model where all inputs are optional? It sounds like this could more easily be dealt with by developing individual, modular models that can be selected based on which inputs the user actually wants to process. Regardless, I think you'll need to do some custom coding.
    – underdark
    Commented Apr 1, 2018 at 17:13
  • I'm trying to build a self checker for people who have very little GIS experience and need a quick way to take shp files from a proprietary software, run them through this process to check for snapping issues, then use the visual aid produced to correct the snapping in the proprietary software (no permissions to import shp files into the software so can't correct outside of it then import). Topology tools were not robust enough since I could say a feature needs to overlap feature 1 or 2 or 3. I want to ensure there are as few clicks as possible for our staff who may find this software foreign Commented Apr 1, 2018 at 17:21
  • I've seem to have created a silly work around where I have made empty shp files for each potential input and as long as I select one it goes through the model. Haven't finished fully building out that process though. I feel like there should be a way to edit the script to just say if this input exist then run if not then stop Commented Apr 1, 2018 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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