[gdal-dev] ogr2ogr polygon cleanup algorithm?

Even Rouault even.rouault at spatialys.com
Tue Feb 28 15:36:07 PST 2017


On mardi 28 février 2017 17:25:51 CET TazMainiac wrote:
> Hi All,
> 
> When I use ogr2ogr to process a shape file (into KML for examle) that has
> "invalid" polygons (self-intersections or other problems) in it, it "cleans
> them up", such that they are valid.  Is there a description anywhere of
> what algorithm it's using to do this cleanup?  

Hum, there's not really such a cleanup algorithm. When writing a shapefile, there's some 
"topological analysis" to figure out which rings of a (multi)polygon are inside others, so as to 
respect the shapefile specification, but that's all. I'd be surprised that self-intersections of a 
ring are corrected for example.

if you want to explicitly remove invalid geometries, you can do something like:

ogr2ogr out.shp in.kml \
  -sql "SELECT * FROM input_layer WHERE ST_IsValid(geometry)" -dialect SQLite

Even


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170301/be9140c8/attachment.html>


More information about the gdal-dev mailing list