[gdal-dev] Minor problem with the OGR clipping

Eric Grosso eric.grosso.os at gmail.com
Wed Mar 28 22:27:04 EDT 2012


Hi,

I was writing a small OGR based script (bash) in order to clip several
shapefiles at the same time.
Thus I used this piece of code: ogr2ogr -clipsrc polygon_selection.shp
output.shp input.shp

Using it, I had the following error: "FAILURE: Invalid geometry. Must be a
valid POLYGON or MULTIPOLYGON WKT"

I checked my polygon_selection.shp file. It was "OGC" valid. Then I checked
the documentation. Apparently it was correct.
So I finally decided to check the code and I understood why I had this
message.

If the filename of the polygon which is used to do the clipping begins with
"polygon" or "multipolygon", the code tries to convert
this argument in WKT.

Here is an code extract of ogr2ogr.cpp  (same for -clipsrc and -clipdst
options):

else if (EQUALN(papszArgv[iArg+1], "POLYGON", 7) ||
EQUALN(papszArgv[iArg+1], "MULTIPOLYGON", 12))


I let you decide what to do (add this very minor problem to the
documentation or change a bit the code,
e.g. "POLYGON", 7 becomes "POLYGON(", 8 could do the trick). That's why I
didn't open any bug report or enhancement request.

First time I write on this list, so I catch the opportunity to thank all
the developers of GDAL/OGR for your wonderful work.

Cheers,
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120329/20753ef8/attachment.html


More information about the gdal-dev mailing list