I have a large global shapefile with thousands of small gaps/sliver polygons between joined polygons (shared borders of countries). I joined the shapefiles using the sf R package, and have attempted to resolve the issue using R as well as QGIS. The closest I've gotten is the workflow below:

  • Create a polygon overlay, take difference, mutlipart to singlepart tool, union tool, create area column with calculated field, eliminate selected polygons tool (selecting the gaps by area in the attribute table). While this approach fixes most of the gaps, many dangling lines are left behind which creates an incompatible GeometryCollection type issue so I can't use any other tools to clean it up (like v.clean rmdangle or fix geometries) without errors or several of the polygons being removed. (I'd like to be able to use this file, since it does the trick for the most part but am unsure how to resolve the GeometryCollection collection error, similar post here)
  • I also tried to find a way to use a country line file with a common id field to snap to the nearest border, but couldn't figure out an approach for that. Any advice for this approach welcomed as well!
  • Currently experimenting with the rmapshaper package to use the snapping function within ms_simplify

I have read a ton of posts about resolving gaps between polygons in a shapefile to no avail although it seems to be a fairly common issue. I saw that the integrate tool in ArcGIS may be an option, but I'm suprised there's not an existing workaround with an open-source tool. Has anyone successfully found a way to resolve their gaps without ArcGIS?

Here are some picture examples enter image description here enter image description here

  • Probably hard to give a working answer to your problem here since you seem to have tried everything that usually works and any solution is possibly going to be tailored to your data. Can you share a sample of your data that illustrates the worst problems?
    – Spacedman
    Commented Aug 30, 2023 at 20:23
  • Thanks for your message, just added some pictures! Commented Aug 30, 2023 at 20:40
  • If you only have a few geometry collection records you might try deleting them, completing your work on what remains, and then add in the missing features. Or using them to identify a problem area and fixing that manually before beginning your process. Or try an old coverage type method. No multiparts. Convert polys to lines and again to points (using point on surface tool & create on surface of each part checked), run a v.clean on the lines, then polygonize the lines, spatial join the points to the polys to add attributes, select polys with no attributes, run eliminate on those.
    – John
    Commented Aug 30, 2023 at 21:09
  • Have you tried snapping the polygon to itself and or snap points to grid?
    – Bera
    Commented Aug 31, 2023 at 5:29
  • The best thing I've ever used for this sort of repair job is pprepair, but I don't think there's a QGIS plugin that implements it and I've always compiled the code and run it standalone on a shapefile. github.com/tudelft3d/pprepair - if you can share your data I'd try and run it for you.
    – Spacedman
    Commented Aug 31, 2023 at 7:53

1 Answer 1


Looks like a projection mismatch from the get-go, as when you got geodata without a projection, and applied a projection to be able to do the spatial operations, but that wasn't the correct projection. Try to figure out what the 'native' project is for each of your files, set that using st_crs, then st_transform to a common projection, and then try the spatial join.

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.