TransWikia.com

Add a QGIS vectorlayer by geometry type

Geographic Information Systems Asked on August 15, 2021

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?

One Answer

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)

Answered by GladH on August 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP