In the attached image you can see that there are features in the shapefile that have the same geographical extent, I would like to find a way to only keep one of them and remove the rest.

I would like to keep the one with the lowest value on the attribute Year. Using the remove duplicate geometries tool, I can't find any way to just keep the feature with the lowest value on the attribute Year.

Is this possible automate with any opensource tool like QGIS or GDAL? There are over 10 000 features so to do it manually is a bit too time consuming.

Overlapping features

  • 3
    Have you had a look at the remove duplicate geometries tool? If so, how does the output not suite your needs?
    – Erik
    Dec 6, 2019 at 12:37
  • I can't find any way to just keep the feature with the lowest value on the attribute Year. But I might have missed it, I'm not that familiar with Qgis. Dec 6, 2019 at 12:44

2 Answers 2


Here's another solution, because it's nice to have options. This solution takes more steps, but it doesn't require PostGIS.

As you discovered, the tool delete duplicate geometries doesn't give you any control over which duplicate gets deleted. It actually says in the description, "Attributes are not checked, so in case two features have identical geometries but different attributes, only one of them will be added to the result layer."

As a workaround, we can do a spatial join to copy the attributes of duplicate features onto their clones. Use the Join Attributes by Location tool to join the layer to itself, with the geometry predicate equals.

enter image description here

The output should be a layer that still has duplicate polygons, but each duplicate polygon has copies of the attributes of all the others. Now you can run the delete duplicate geometries tool. Regardless of which polygon it deletes, the remaining polygon will have all the information from the one you wanted to preserve.

Then downside of this method is you end up with extra information in the attribute table. Cleaning it up could be tricky.


Well, the answer was right in front of me. I will just import the shapefile into my PostGIS database and then remove the "newer" duplicates with a SQL query.

Used this SQL query.

    geo.ekonomiska a
        USING geo.ekonomiska b
    a.Year > b.Year 
    AND a.storruta = b.storruta AND a.ekoruta = b.ekoruta; --Identifiers to see that it's the same map
  • Would you mind adding the SQL query to your answer? That would be helpful for others with the same question. (It might be possible to use the same query to create a virtual layer directly in QGIS.)
    – csk
    Dec 6, 2019 at 18:46
  • Updated the answer with the SQL I used Dec 7, 2019 at 14:27

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.