Using an attribute field, I want to dissolve overlapping features according to a specified order. For instance, if I have three overlapping features, like the image below, I'd want to keep the purple feature, then the red one and then what's left the remaining feature

Three overlapping features with different attributes

Dissolving would look like this.

Result of the dissolve process with specified order

I would need to do this with thousands of features so editing manually is not an option.

  • 1
    What you are looking for is "Difference", not "Dissolve"
    – MrXsquared
    Commented Dec 21, 2020 at 19:14
  • 1
    What do you mean by dissolve? What I understand is that you would like to specify the order of features based on an attribute value. ?? Commented Dec 21, 2020 at 19:18
  • Features are in the same layer, so I guess difference would not be an option. Also, i need to change the features and cant have overlaps. If 1 overlaps 2 and 3 for instance, then the new feature aggregates all three.
    – CAN84
    Commented Dec 21, 2020 at 19:46
  • If you are ok with using postgis: gis.stackexchange.com/questions/379300/…
    – Bera
    Commented Dec 22, 2020 at 7:53

3 Answers 3


You can use "Control feature rendering order" option under "Layer Rendering" in "Layer Style" panel.

enter image description here

Open Define Order window by clicking AZ button. Add field name (Type here) and values (1: purple, 2: red, 3: green).

enter image description here


enter image description here


enter image description here

  • Kadir that would suit me but it will only change how I view the features, not actually change them. In your example features still overlap.
    – CAN84
    Commented Dec 21, 2020 at 19:44
  • 2
    Then, what do you mean by Dissolve? If you dissolve features, you lose the colors and three features become one feature. Commented Dec 21, 2020 at 19:48
  • Ok then lets put it this way. I have several overlapping features. They have a field which classifies them. I want to a have aggregated features (no overlaps) according to a hierarchy. If feature with code 1 overlaps codes 2 and 3, then the feature keeps code 1. If a feature with code 2 overlaps one with code 3, then the resulting feature will have code 2. And so on
    – CAN84
    Commented Dec 21, 2020 at 19:59
  • 1
    I'm sorry. I couldn't understand what exactly you would like to do. :( Commented Dec 21, 2020 at 20:09
  • 1
    My instinct tells me you might need a script. Commented Dec 21, 2020 at 20:10

There is actually a solution to this problem that does not require a script. It requires multiple processing steps, but you could chain these tools together in a graphical model.

I'm using QGIS, but I believe this could be done in ArcMap in a similar fashion (though perhaps using different tools).

Say you have three features in a single layer that overlap like so:

overlapping rectangles

Step 1: Reassign the primary key column (in my case ID) for the layer so it reflects the order in which you'd like the overlaps retained. So the feature with ID = 1 will be left completely intact, feature 2 will be prioritized over feature 3, feature 3 over feature 4, and so on.

Step 2: Run Union, setting the layer as the only input (leaving the Overlay layer empty). This will perform a Union between the layer and itself, resulting in (in my case) 12 features.

Union screenshot


Union output

Step 3: Run Delete Duplicate Geometries on the output from Step 2. This reduced the number of features to 7.

Delete Duplicate Geometries screenshot

Step 4: Run Join Attributes by Location, setting the Base Layer to the output from Step 3, the Join Layer to the original layer from Step 1, the Geometric predicate to "within", and the Join type to "Take attributes from the first matching feature only (one-to-one)". This is where the magic happens, since the first matching feature in each case is determined from the order of the primary key.

Join attributes by location screenshot

Step 5: Finally, run Dissolve, setting the Dissolve field to "ID_2", which is the ID of the original features that were joined in Step 4.

Final result:

final output

  • Many thanks Mike, solves it wonderfully. Thank you!
    – CAN84
    Commented Dec 22, 2020 at 18:28
  • I've tested but stumbled against another issues. In my case, the order is not a primary key (i.e. they are not unique, just a field where I set the order; several features have order 1, others order 2, etc.). Would there be a way to give the mininum value (highest rank) to the feature? Another way could be to give a primary key starting with the highest ranking to the lowest? Or avoid the primary key (which I'm not sure how to assign or reassing) altogether and just give the feature the minimum value when joining by location?
    – CAN84
    Commented Dec 23, 2020 at 8:59
  • This method will only work if the order is also the primary key, which is also unique. Are you using QGIS? If your primary key is "id", you should be able to reassign it from swither field using field calculator, but you'll first need to make it unique. If you want to use another field for the order that is not unique, I think you'll have to write a script as I haven't found a way to do it. Commented Dec 23, 2020 at 15:50
  • Thnaks Mike. The field is not unique so I found a workaround which works despite the time it takes. I first separated the shapefile into several others based on the unique values of the field that gives the order of overlay. For each file I created an identifier field. I then made an union with the graphic model of all files. The resulting file has the same number of identifier fields as the number of files. I then created a new field where I had a CASE when then function. E.g.: when field4=1 then newfield=4, and so on according to the order I wanted. Perhaps I bit confusing, but it worked.
    – CAN84
    Commented Dec 24, 2020 at 16:16

You can use Union - Aggregate - Dissolve.

I have a field called prio in my polygon layer, and where polygons overlap I want to keep the lowest prio value. So for example when a prio 1 and prio 2 overlaps, I want to erase the prio 2 polygon overlap:

enter image description here

Then Dissolve by prio field with the option keep separate features disjoint ticked.

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.