How do I select all features in a polygon layer that intersect (overlap) a line feature?
I need to implement this in python using QGIS, thus pyqgis. This code illustrates what I am looking for (line 10 is sort of pseudo-code, i.e. what I am looking for):
1 area_layer_file = "./Areas.shp"
2 line_layer_file = "./Lines.shp"
3
4 area_layer = QgsVectorLayer(area_layer_file, "Areas", "ogr")
5 line_layer = QgsVectorLayer(line_layer_file, "Lines", "ogr")
6
7 areas = []
8 for line_feature in line_layer.getFeatures():
9 request = QgsFeatureRequest(QgsExpression(
10 area_feature.geometry().intersects(line_feature.geometry())
11 ))
12 areas = [area for area in area_layer.getFeatures(request)]
This image illustrates my question: the red line intersects the yellow selected areas.