[gdal-dev] Clipping shapefile with another produces invalid shapes

Even Rouault even.rouault at spatialys.com
Fri Oct 13 04:01:19 PDT 2017


On vendredi 13 octobre 2017 09:06:46 CEST Paul Meems wrote:
> Thanks Even for your quick reply.
> 
> I was using MapWinGIS to perform the validation and I assumed it was just
> using GEOS.
> I did a closer look at the code and it is first doing some internal checks
> like the minimum number of points and the order of the points.
> The code is checking if the polygon shape only has 1 part. If so it should
> be clockwise.
> After that, it is using the GEOS:IsValid method.
> As I understand you correctly I should interpret this message as a warning,
> not as an error.

Different software, standard, formats have differen rules on if there must be a winding order 
and which one it is...

A return of false by GEOS:IsValid() should be examined a bit more closely (but apparently you 
get this error before calling IsValid())

> 
> I also tried your suggestion:
> ogr2ogr -sql "select ST_ForceLHR(geometry) from ogr_clipped" -dialect
> sqlite ogr_clipped_lhr.shp ogr_clipped.shp

Jukka answered on the LHR vs RHR confusion, but I completely missed the fact that you were 
outputting to shapefile. In that case, whatever the original orientation, or if you modified it 
with a SQL statement, the OGR shapefile writer will force the polygons to follow the 
shapefile specification, which requires the outer ring to be in clockwise order. So you 
shouldn't get this error... Which means that either there's an issue in some case in the 
shapefile driver (numerical precision issue), or in the check in MapWinGIS.

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/20171013/52d72770/attachment-0001.html>


More information about the gdal-dev mailing list