You can use Union, Delete duplicates by attribute together with Sort, to delete duplicate geometries except the first.
I have a field named prio with values from 1-5. Where polygons overlap I want to keep the lowest prio polygon, for example 1 should be kept over 2.
Field calculate an id field: @row_number
to get a unique identifier for each polygon
Union your polygon layer with itself as Input layer, no overlay layer. This will create duplicate geometries where polygons overlap
Field Calculate a text field named wkt with the formula geom_to_wkt( $geometry )
Duplicate polygons from the Union will get the same wkt string.
Order by expression with the expression concat("wkt","prio")
so for each duplicate geometry, the lowest prio comes first (1,2,3,4,5)
Delete duplicates by attribute wkt:
Deletes duplicate rows by only considering the specified field /
fields. The first matching row will be retained, and duplicates will
be discarded.
So for duplicate geometries, the first (lowest prio number) polygon will be kept.
- Dissolve by the id field created in step 1 to restore some of the split geometries created in the Union.