0

In QGIS, how do you remove overlapping polygons and control which polygon gets deleted? I’ve used the delete geometries tool to remove overlapping polygons within a layer but this doesn’t allow me to specify which overlapping polygon gets deleted. This is a problem because some polygons are more important than others. Can I use an attribute value to establish an order of priority when deleting overlapping polygons? I have a lot of polygons so manually removing overlap between them isn’t an option.

1 Answer 1

1

I try to give you a solution using a sample data set of three polygons. Polygons have a unique ID and a PRIORITY columns. enter image description here (polygon fill is 50% transparent to see the overlapping parts).

Convert the polygons to lines (we'll use these lines to split the polygon layer) using Vector/Geometry Tools/Polygons to Lines... from the menu. You'll get layer Lines memory layer if you don't change settings.

enter image description here

Split the original polygon layer by the Lines layer using Processing Toolbox/Vector Overlay/Split with lines

enter image description here

You get a Split layer where the overlapping areas are separated (but duplicated):

enter image description here

Using the DB Manager plug-in let's select only the necessary elements:

select a.geometry, a.id, a.priority from Split as a
    where st_area(a.geometry) > 0.001 and not exists (select b.id from Split as b
        where a.id <> b.id and st_contains(a.geometry, st_centroid(b.geometry)) 
        and a.priority > b.priority)

enter image description here

This Query Layer doesn't contain duplicates, but it should be dissolved by the original unique IDs. Using Dissolve from the Processing Toolbox we can join the areas with common IDs.

enter image description here

And here is the result:

enter image description here

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.