I am trying to script the clipping of overlapping areas from a set of polygons. After having fetched features (outerFeature) a loop (innerFeature) is to check if other features intersect with area > 0. I then try to clip the intersecting area. Apparently difference does not give the right result.
#Intersecting features
for outerFeature in pr.getFeatures():
#Looping through all features and check if intersect
for innerFeature in pr.getFeatures():
geom = None
if outerFeature.id() != innerFeature.id():
geom = outerFeature.geometry().intersection( innerFeature.geometry() )
#If intersection area > 0, then construct difference and update geometry
if geom.area() > 0:
print("intersecting and clipping")
outerFeature.setGeometry( geom.difference( outerFeature.geometry() ) )
vl.updateExtents()
Any advise is highly welcome.
Best regards
Sebastian


