To get selected features I usually do: layer.selectedFeatures()
.
Is there a method to retrieve selected features in a list without specifying the layer they belong to ?
I selected features with the "Selection by location" tool:
processing.run("native:selectbylocation",
{'INPUT': "C://path/file1.shp",
'PREDICATE':[0,4,7],
'INTERSECT':"C://path/file2.shp",
'METHOD':0})
The features I am seeking are indeed selected in my QGIS environment. Now I would like to delete them with PyQGIS but I don't know how to retrieve and put them in a list since I didn't create a QgsVectorLayer
object for my shapefile.
Do you know a way to either retrieve the selected features or the layer they belong to ?
{"OUTPUT": "C://path/file1.shp"}
. So I tried to store that output in a QgsVectorLayer object, but there is 0 selected feature when I try to count them withselectedFeatureCount()
. Even though the same layer already displayed in QGIS has some selected features in its attribute table.