I have thousands of polygons in a layer. I am using following code to delete one of two intersecting polygons from a layer by checking geometry intersection of each polygon with all others. But it results in deleting both the intersecting polygons. How to delete only one instead of both? Also, this code is taking too long as there are many features in the layer. Is there any way to speed it up?
features=[f for f in layer.getFeatures()] layer.startEditing() for n in features: geom = n.geometry() if any(geom.intersects(init.geometry())==True for init in features if n.id()!=init.id()): layer.deleteFeature(n.id()) layer.commitChanges()