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.
- Repairing geometry using QGIS?,
- Cleaning polygon after using dissolve to repair geometry in QGIS? and
- Fixing geometry validity errors in QGIS?
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:
(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?