For some reason my code is not doing what I expect it to do.
from qgis.core import * from qgis.utils import iface import processing # Load the layer layer = iface.mapCanvas().currentLayer() bluespaces = QgsExpression ( " \"ITEM2012\" = 'Wetlands' OR \"ITEM2012\" = 'Water'") selection = layer.getFeatures(QgsFeatureRequest(bluespaces)) ids = ([k.id() for k in selection]) layer.setSelectedFeatures( ids ) newlayer = QgsVectorFileWriter.writeAsVectorFormat(layer, 'U:\PythonTest\bluespaces.shp', 'System', QgsCoordinateReferenceSystem(25382), 'ESRI Shapefile', bool(True))
This should give me a shapefile containing the blue spaces from the input layer. It works fine with other selection criteria and I checked if something was wrong with the selection criteria used above numerous times, but to no avail.
Can someone tell me what I am doing wrong?