13

I am attempting to mask a raster to US Forest Service boundaries in QGIS. It fails due to self - intersections of polygons.

Warning 1: Ring Self-intersection at or near point -109.90112962000001 43.649977879999994
ERROR 1: Cutline polygon is invalid.

I have run the check validity tool and a new shapefile is created but it too finds the same error when attempting to mask the raster to the "valid" shapefile.

I have also attempted to dive into the v.clean tool with unsuccessful results using both bpol and snap separately. I don't fully understand what this tool is doing, but it outputs a number of polygons that match some Forest Service land but excludes the majority of their land.

I also ran v.build.check to find topological errors and it created an output that is seemingly empty. Nothing in the attribute table, nothing visible on the map.

There have been similar questions on here but I haven't been able to make their solutions work.

I downloaded and used GRASS to attempt to fix the self-intersecting polygons. GRASS upon v.in.ogr recommended I snap at 1e-6. I did this and the output said I had 1 area overlapping left when previously I had thousands. So I saved the shapefile and imported to QGIS to being my analysis over there. The check validity tool found 185 self-intersecting polygons.

example1

Still unable to use the clipper to create a Mask, I decided to look at the error output on the Map. The snapping tool isn't fixing these nodes.

example2

Here's a larger picture of the area.

example3

I wonder if it would be easiest just to dissolve these shapes in some way.

4
  • Could you find the polygon that is claimed to be faulty and add that into your question as WKT?
    – user30184
    Dec 18, 2017 at 9:36
  • I used the topology checker for this and found 37 polygons with invalid geometry at that point I wasn't sure what to do.
    – apetbrown
    Dec 18, 2017 at 19:01
  • Did you solve your question?
    – nanunga
    Jun 29, 2018 at 10:49
  • Dissolve didn't work for me., the tool actually fails on the invalid geometry. So its not a viable solution. In theory it would make sense though. I also tried a Multi-part to single part, and then dissolve. This didn't work either. Additionally, if ound the 'is valid' checks, would only identify the 'first' self-intersection on a polygon. I had a poly which had an error, I fixed it, then ran the check again, it found a new error.... 5 error fixes later.....
    – nr_aus
    Jul 30, 2020 at 7:12

4 Answers 4

42

When I get errors like this I usually find applying a zero distance buffer can fix the geometries. So use the buffer tool in QGIS and set the buffer distance to 0 units. Then try and use this buffered layer as the mask.

3
  • Thanks, this seems to have worked so far. Though while reading the log as the mask was created it did state there were overlapping issues it was ignoring and that the centroid of the polygon could not be found.
    – apetbrown
    Dec 18, 2017 at 19:00
  • Works like a charm wit the Eurostat file (NUTS_RG_01M_2016_3857_LEVL_0.shp), which give errors for France, Norway and Germany. Nov 16, 2019 at 22:10
  • Worked as a charm. please accept this answer. Mar 2, 2021 at 6:34
2

Further to the above answer of 0 buffer distance - this didn't work for me, HOWEVER I will give credit to the author for leading me down the right path. I actually ended up applying a 1mm buffer and dissolving the result. I would recommend dissolving as a secondary step, because you may wish to apply different dissolve parameters (as opposed to using the 'Dissolve' option inside of the Buffer tool).

This fixed the self-intersection issues I was experiencing. The resultant area increase was negligible. This number may need to be adjusted based on need and tolerances, but 1mm (millimeter) increase for non-real world objects was an acceptable distance.

2

I managed to fix a similar issue by clicking on Toggle Editing and then using the Node tool to highlight all the vector nodes and then manually adjust the location where the ring self-intersection point was found.

1

I managed to clip a vectorized raster just like the one in your picture after doing a "multipart to single part" and it didn't skip any polygon, though it keeps displaying the polygons with the overlapping vertices.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.