[Gdal-dev] OGR, SHP, and multi-polygons

Frank Warmerdam warmerdam at pobox.com
Thu Feb 5 09:03:57 EST 2004


Ben Discoe wrote:
> I've got code which is using Shapelib to read SHP files.  It is not handling
> some polygons correctly, so i am trying to change to using OGR instead, in
> the hopes that will solve the issue.
> 
> The issue is that some SHP files, including some that are example files that
> ship  with ESRI software, like 'CNTRY92.SHP', are of type 'Polygon' but
> actually contain MultiPolygons.  E.g. the USA is represented as a single
> polygon (!) including Alaska and Hawai'i.
> 
> When i use Shapelib, it gives me a number of 'parts' (nParts) per polygon.
> The information apparently lacking is which 'part' is the exterior, and
> which which 'parts' are wholes.
> 
> Switching to OGR, the problem remains.  There is only one ExternalRing,
> which is _definitely_ not right; in the above example data, if we use only
> the ExternalRing, then we get a small island off the coast of Alaska, and
> the rest of USA is not loaded.
> 
> I'm left wondering - is there any way to successfully load SHP files like
> this with either Shapelib or OGR?

Ben,

What version of OGR are you using.  Patches were introduced in the fall some
time to try and classify rings properly and form correct multi-polygons when
reading from Shapefiles.   This did not exist in GDAL 1.1.9 so you will need
a nightly snapshot.

This code is likely not bullet proof, so if you are still running into
problems I would appreciate your providing the dataset in question.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list