I have a polygon and some features are below another features. If I would have two different polygons I would use the "Difference" tool so it would take the overlapping feauters to the "surface".

Does anybody knows a method (if there´s any) on how to do a kind of difference tool but with different features in the same polygon?

  • 2
    Could you please quickly sketch a picture (printscreen) of what you have currently and how you want to see it? I am a bit lost in what you mean by "difference of different features in the same polygon".
    – Miro
    Commented Aug 26, 2020 at 1:24

2 Answers 2


Is creating the magenta polygons where the polygon layer intersects itself what you are trying to do? If so you can use pyqgis and intersect all combinations of polygons:

enter image description here

from itertools import combinations

layer = QgsProject.instance().mapLayersByName('Overlaps')[0] #Change to match your data

intersections = []
for poly1, poly2 in combinations(layer.getFeatures(), 2):
    if poly1.geometry().intersects(poly2.geometry()):

vl = QgsVectorLayer("MultiPolygon?crs={}&index=yes".format(layer.crs().authid()), "intersectionsLayer", "memory")
provider = vl.dataProvider()
for poly in intersections: 
    f = QgsFeature()


If I understood the question correctly, you want to achieve two layers:

  • First that contains only overlapping features
  • Second that includes features with no overlaps

Let's assume there is a polygon layer "grid" with its attribute table accordingly, see image below.


Step 1. Apply the SAGA's module "Polygon self-intersection"


Step 2. Apply the following expression if("ID" LIKE '%|%', 0, 1) in the Field Calculator.


Step 3. Continue with a "Split vector layer" using the "key"-field created at the Step 2. Application of "Fix geometries" on this step may be necessary. And get the output, see image below.


Note: Mind that the final output(s) is(are) in .gpkg-format.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.