I'm new to PyQGIS, I'm trying to select all polygons in my map layer (Crops) that are intersected by my radius polygon layer (buff), However every time I run the below code, polygons that are not intersected by the radius are selected.

areas = []
for area_feature in buff.getFeatures():
    next = Crops.getFeatures(QgsFeatureRequest().setFilterRect(area_feature.geometry().boundingBox()))
    for area_feature in next:
        if area_feature.geometry().intersects(area_feature.geometry()):


  • 2
    Don't use the same loop variable name for nested feature iterators of two different layers.
    – Ben W
    Commented Apr 4 at 2:02


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.