I have a shapefile where the geometry is a mess, lots of gaps, slivers, and holes. I need to correct these geometry errors, but I am having trouble with the process.

I have read the pages here, here and here, and looked at the SE questions:

amongst others, and the GRASSwiki pages.

However, I am still uncertain about the steps I should be taking to correct these, particularly the best workflow and the settings I should use.

I can't seem to get anywhere with Dissolve or Eliminate Sliver Polygons, and so I have been experimenting with GRASS in QGIS.

Currently, my steps are;

  • Check for errors on the file using Vector > Geometry Tools > Check Geometries, (I have tried with Topology Checker but it keeps crashing Q). I have been using these options:

enter image description here

(Check Geometries says there are 3330 errors (in a shapefile with only 1900 polygons). I have tried fixing some of these in the Results tab of Check Geometries, but it is very slow and each time I resolve one error it finds 1000+ more. So I have been attempting to use GRASS instead)

Steps I'm using

  • Open GRASS mapset and import the shapefile using v.in.ogr I opted for snapping of 9 because that seems to preserve the data. The ‘pixels’ are 10m x 10m, if I increase the snapping tolerance to 10 some of the gaps begin to fill in but the square pixels begin to warp, and some of the polygons are no longer imported.

  • Basic import into GRASS and export again (with minimum area of 101) leaves 2330 errors. So start trying to improve the errors using v.clean (should I untick centroids for any of these?) bpol, break, rmdupl, rmarea (threshold = 101, ie. > one pixel).

  • Export with v.out.ogr (with 'centroids' unticked).

  • Check the shapefile with Check Geometries again. Only removing the smallest polygons, (either during import or with 'rmarea') seems to have any effect.

I’m left with 2325 errors, all either ‘Polygon with hole’ or ‘Sliver polygon’. This still seems like a huge number of errors. The ‘sliver’ polygons are small, but they are not 'errors' in the sense that I want to retain them for future analysis. And can polygons really not have holes? I don’t really want to have to delete any more than I absolutely have to. The shapefile is based on a landcover classification, and if I start to alter the image too much it will lose its value.

So, to sum up:

  • Are these steps the right ones?

  • If they are, why have I still got so many errors?

  • And, how can I resolve them without losing too much information?

  • If everything is wrong with your shapefile I think you should focus on one thing that is wrong with it and describe precisely what you did to try and fix just that and where you are stuck.
    – PolyGeo
    Jul 27, 2016 at 12:00
  • @PolyGeo - I have given detailed information on what I've tried, and explained what my issues are. Despite following the details in other SE questions and on the web generally, I cannot resolve the errors I have. I don't know why this is the case, hence posting my question.
    – EcologyTom
    Jul 27, 2016 at 12:54
  • I'm not able to offer more detailed advice at the moment so I'll re-open.
    – PolyGeo
    Jul 27, 2016 at 13:12
  • Thanks @PolyGeo, I'd really appreciate the community's thoughts
    – EcologyTom
    Jul 27, 2016 at 13:32
  • 1
    I've just been through a similar scenario on a smaller scale. I found it useful to focus on one thing at a time. The first category, for example - self intersections and duplicate nodes. Once you clean those up many of the other problems will also go away. It should be trivial to write a python script to remove duplicate nodes, in fact a canned tool must exist for that somewhere.
    – marcp
    Jul 27, 2016 at 16:09


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.