QGIS Self-Intersection – Fixing Polygon with Ring

qgisqgis-2.18ringself-intersection

When I polygonize a raster, I very often have 'pixels' holes/interior ring that touche exterior ring.
Example :

POLYGON((5 0, 10 0, 10 10, 0 10, 0 0, 5 0, 3 3, 5 6, 7 3, 5 0))

ring self intersection

It's defined as an invalid geometry in the OGC geometry specifications.

In QGIS, how to fix this ?

Best Answer

I've found the solution here but for Postgis : https://gis.stackexchange.com/a/15301/93097 and I've test it in Spatialite/Virtual layers, and it works !

Bellow the code I use with a shapefile 'my_layer' with one field 'DN' :

SELECT DN,
ST_Buffer(geometry,0.0) as geometry
FROM my_layer;
Related Question