I wanted to add a GML layer to my QGIS file, but filtered by geometry type. (the file has multiple geometry types in it, with the same layer name, and same layerID.

I came across this post: iface.addVectorLayer on a gml file causes "Select vector layers to add" dialog (pyqgis).

Here they filter it by "|layername="+name

But how can I filter it by geometry type?


1 Answer 1


You can filter it by "|geometrytype=Point" or "|geometrytype=CurvePolygon" or "|geometrytype=LineString"

It will look something like this:

vlayer = QgsVectorLayer(file_open + "|geometrytype=Point", "vlayer_name", "ogr")
if not vlayer.isValid():
    print("Layer failed to load!")

Your Answer

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

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