1

Attempted to extract raster by mask layer in QGIS 2.18.15 and for one of my shapefiles, the command could not be executed. The error message reads "Warning 1: Ring Self-intersection at or near point 97.520362854004077 18.494590759277401 ERROR 1: Cutline polygon is invalid."

I executed the Check Validity function, and identified the source of this self-intersection. Self-intersection

In trying to correct this 1 error, I have tried the following

  • (1) added a zero distance buffer using QGIS default plugin
  • (2) added a zero distance buffer using GRASS v.buffer.distance
  • (3) used multiple permutations of GRASS's v.clean & v.clean.advanced

But none of the above has rectified this issue i.e. when I run the Check Validity function, the error still persists. I have browsed through several threads within this forum but their solutions don't seem to work for me.

  • 1
    To get rid of this goemetry problem you have to change the geometry in one of two ways: 1. Open up the polygon by moving the two touching vertices away from each other. 2. Create a proper hole by introducing a bridge across the area where the two vertices touches. I don't know if either method exist in modern GIS software. – Chau Aug 10 '18 at 6:48
  • 1
    Strange that buffer by zero hasn't worked in this case. What format are you storing this polygon in? If you are storing it as sqlite, geopackage or in PostGIS you could try st_makevalid? – Phil Barlow Aug 10 '18 at 8:12
  • 1
    zero distance buffer and v.clean should generally fix your issue. Is it possible to share your geometry? Another tool that I recommend is mapshaper.org - you will get a prompt to fix line intersections, try that and export to see if the issue gets fixed. – spatialthoughts Aug 10 '18 at 8:42
  • 1
    Could you compare these two geometries: POLYGON (( 0 160, 60 160, 60 120, 30 120, 40 140, 20 140, 30 120, 0 120, 0 160 )) and POLYGON (( 30 120, 0 120, 0 160, 60 160, 60 120, 30 120 ), ( 30 120, 40 140, 20 140, 30 120 ))? Which one QGIS does not like? Difference is if outer ring is touching itself at one point or if there is an inner ring that is touching the outer ring. – user30184 Aug 10 '18 at 11:23
  • 2
    as well as v.clean, try the QGIS "fix geometries" - note that there are two options, QGIS and GEOS. Worth trying both. – Steven Kay Aug 10 '18 at 16:50
4

After downloading QGIS 3.2.1 'Bonn' and using the "Fix Geometries" function (which is described very similarly to ST_MakeValid in PostGIS), the previously invalid polygon is made valid i.e. it does not turn out to be invalid after using 'Check Validity'.

It seems though that the inversion is still present in the layer despite it being a valid polygon now. Fortunately for me, this inversion is much smaller than the spatial unit I am working on, and its influence on data quality as a whole is not markedly detrimental.

Thank you one and all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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