Skip to main content
Tweeted twitter.com/StackGIS/status/1380445386838523905
Became Hot Network Question
converted into a proper question
Source Link
Noura
  • 3.4k
  • 3
  • 20
  • 41

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?

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 you can also 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,

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?

Source Link
GladH
  • 65
  • 5

Add a QGIS vectorlayer by geometry type

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 you can also 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,