Saturday, 14 October 2017

How to fix polygon with ring self intersection in QGIS?


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 ?



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;

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...