3

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?

0

1 Answer 1

2

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!")
else:
    QgsProject.instance().addMapLayer(vlayer)

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.