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

Paul Meems bontepaarden at gmail.com
Fri Oct 13 00:06:46 PDT 2017


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.

I also tried your suggestion:
ogr2ogr -sql "select ST_ForceLHR(geometry) from ogr_clipped" -dialect
sqlite ogr_clipped_lhr.shp ogr_clipped.shp
It is very fast, only a few seconds on my 700k shapes, but the result is
the same. I still get the 'Polygon must be clockwise' error.
Of course, MapWinGIS also has a fix method, but it is very strict and not
so fast with 700k shapes.

I'll send the resulting shapefile to my client and ask if his application
can process the data.

Thanks,



Paul

*Paul Meems *
Release manager, configuration manager
and forum moderator of MapWindow GIS.
www.mapwindow.org

Owner of MapWindow.nl - Support for
Dutch speaking users.
www.mapwindow.nl


*The MapWindow GIS project has moved to GitHub
<https://github.com/MapWindow>!*


Download the latest MapWinGIS mapping engine.
<https://github.com/MapWindow/MapWinGIS/releases>

Download the latest MapWindow 5 open source desktop application.
<https://github.com/MapWindow/MapWindow5/releases>

2017-10-12 23:28 GMT+02:00 Even Rouault <even.rouault at spatialys.com>:

> Paul,
>
>
>
> > But at the red asterix, I have an invalid shape. The reason is according
> to
>
> > GEOS:
>
> > Polygon must be clockwise
>
>
>
> I can't see such error emitted by GEOS source code.
>
>
>
> even at even-i700:~$ grep -r "must be clockwise" geos/
>
> even at even-i700:~$
>
>
>
>
>
> Are you sure this comes from it ? As far as I know, GDAL and GEOS are
> pretty much indifferent regarding the winding order of polygons. Other
> tools might be more sensitive.
>
>
>
> You could possibly use the ST_ForceLHR() function of spatialite (through
> the SQL SQLite dialect) to post process your result:
>
> http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.2.0.html
>
>
>
> 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/79d43820/attachment.html>


More information about the gdal-dev mailing list