1

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?

EcologyTom
  • 551
  • 5
  • 16
  • 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 '16 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 '16 at 12:54
  • I'm not able to offer more detailed advice at the moment so I'll re-open. – PolyGeo Jul 27 '16 at 13:12
  • Thanks @PolyGeo, I'd really appreciate the community's thoughts – EcologyTom Jul 27 '16 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 '16 at 16:09
  • Thanks @marcp, but do I have any self-intersections or duplicate nodes? (And if yes, how can I find out if I have?). The Check Geometry only lists 'Slivers' or 'Polygons with Holes' errors. – EcologyTom Jul 27 '16 at 16:52
  • See also: http://gis.stackexchange.com/questions/201316/how-to-use-the-check-geometries-plugin-for-polygons – eclipsed_by_the_moon Jul 27 '16 at 17:30
  • @EcologyTom you might try using the SAGA 'remove duplicate points' tool. I'm unfamiliar with it, but presumably it does what it says! – marcp Jul 27 '16 at 21:56
  • @marcp, I've tried running the SAGA tool, I get errors, I think because it is a polygon rather than point file... I've also no Duplicate Nodes show up when I run Check Geometry – EcologyTom Jul 28 '16 at 06:33
  • @eclipsed_by_the_moon yes, it looks like there are some similarities with your issues. Did you manage to resolve them? – EcologyTom Jul 28 '16 at 06:36
  • I suppose you have to run the checks sequentially: 1. Self-Intersection 2. Minimal polygon area 3. Minimal angle between segments 4. Duplicate nodes. But I'm not sure about the gaps/overlaps check. Please node that you don't have to fix holes in polygons in all cases. The default value for 'Maximum thinness' should be '20' instead of '1'. Most likely this is a bug. – eclipsed_by_the_moon Jul 28 '16 at 19:43
  • @eclipsed_by_the_moon, yes I had been experimenting with adding the checks sequentially. I've 'removed' the Slivers errors by changing the 'Minimum Polygon Area' to 100. So they were never errors, just the Check Geometry reported them as being so. The 'Polygons with Holes' remain however. I think I need to address them because further analysis fails due to errors (unfortunately without specifying what the errors are). However, the Check Geometry Validity tool doesn't find anything. I'm think I'm more clueless about this whole process now than I was when I started... – EcologyTom Jul 29 '16 at 08:39
  • I think you should follow the advice in http://gis.stackexchange.com/questions/203685/resolving-geometry-errors-in-qgis#comment309493_203685 i.e. revise this question to focus on one type of error in one small area at a time. By doing that you are likely to better understand the multiple issues that you are dealing with. Big problems almost always succumb to re-working as multiple small problems. Here we do that as highly focussed separate questions. – PolyGeo Aug 02 '16 at 22:25

0 Answers0