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).
hereHere they filter it by "|layername="+name
but youBut how can alsoI 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)
I wasn't sure if I should post it there or make a new post, but maybe this will help some people in the future,geometry type?