I made my first working script by selecting features on a layer with the Python console. Now i want to export the selected features to a GML or GPKG, but i cannot find any info on how to do so.
I did find SHP, but that causes Qgis to become unresponsive. Is there any way that i can do this?
The original file from which i made the selections is a CityGML, i do not know if that causes any issues. I would like to be able to this regardless of original file type.
Hope somebody can help me out
It did export, but there was nothing in the layer... Also it took forever, but when i manually export the selection its done in a second
layer = QgsProject.instance().mapLayersByName("bgt_wegdeel TrafficArea")[0]
iface.setActiveLayer(layer)
layer.selectByExpression( "\"function\"='rijbaan regionale weg'" )
fn = 'D:\ExportTest\Regionaleweg'
writer = QgsVectorFileWriter.writeAsVectorFormat(layer, fn, 'utf-8', \
driverName='GPKG', onlySelected=True)