Can I edit this code below to show only point layers?

This is being used in a Plugin for QGIS 2.

I am creating if that makes any difference.

self.addParameter(ParameterVector(self.INPUT, self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_ANY]))

1 Answer 1


Answer for QGIS 2.18

You can according to the QGIS code base by using ParameterVector.VECTOR_TYPE_POINT instead of ParameterVector.VECTOR_TYPE_ANY. You need to do import using from processing.core.parameters import ParameterVector

Info extracted from QGIS 2.18 code base file https://github.com/qgis/QGIS/blob/ltr-2_18/python/plugins/processing/script/ScriptAlgorithm.py#L203

For QGIS 3.x, it should be

# At the top of your file
from qgis.core import QgsProcessing

        self.tr('Input layer'),

The enum for other types of geometry for QGIS 3 can be seen in https://qgis.org/api/classQgsProcessing.html#acad4d2322342455b53eee5701e2b3115

  • That's what I thought but still not working. Tried LINE and POLYGON. It's not filtering so I guess there is an issue with my "bindings"? I am using Qgs Widgets in QT designer, renamed the map layer combo box to INPUT but always get all layers?
    – Clutch
    May 2, 2020 at 18:13
  • Normal, you are mixing things. The "map layer combo box" is using the class QgsMapLayerComboBox. If you want to filter, you have to set filters like at webgeodatavore.github.io/pyqgis-samples/gui-group/… You will need to replace in the sample, the line map_layer_combo_box.setFilters(QgsMapLayerProxyModel.VectorLayer) with map_layer_combo_box.setFilters(QgsMapLayerProxyModel.PointLayer). The sample code you mentioned is for processing algorithms
    – ThomasG77
    May 2, 2020 at 22:06
  • Thx Thomas, yea I was also creating a script based on that method as well. Seems if I go the Parameter route I get the errors like above and if go Qgs route I get unrecognized module errors? So I have been battling this for many weeks with no success. Should anyone care to help set me straight via Skype would much [email protected].
    – Clutch
    May 4, 2020 at 1:41

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.