Is there any way to force input parameters (e.g. data provider, geometry type, field type) in processing scripts?

enter image description here

enter image description here

  • What have you attempted thus far? – whyzar Jan 3 '17 at 16:22
  • are you familiar with the Graphical Modeller? Or do you need fields to be made mandatory/required outside of the modeller, e.g. running a single algorithm from a Python script? – Steven Kay Jan 3 '17 at 21:28

For processing scripts, I don't think it is currently possible to filter out a layer's data provider specifically for PostGIS layers. Looking at the parameters.py file for the processing framework, it seems that you can only specify the following for all loaded shapefiles:

  • Geometry type: (point, line or polygon)
  • Field type: (number, string)

So currently, you could use something like:

##Input table=vector point
##Distance field=field number Input table

You could try and edit the file to include a PostGIS parameter (not sure how much editing is required) which you can find in your QGIS directory. E.g.:

C:/Program Files/QGIS 2.18.2/apps/qgis/python/plugins/processing/core/parameters.py

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.