[gdal-dev] GDAL, ESRI Shapefiles and nested polygons

Even Rouault even.rouault at spatialys.com
Thu Aug 7 13:26:51 PDT 2014


Le jeudi 07 août 2014 22:20:34, Graeme Wilkie a écrit :
> Hi,
> 
> I'm trying to use GDAL to read ESRI shapefiles. I've got it working for
> points, lines, polygons, polylines and multipoint but I'm having problems
> with polygons that contain polygons in the same feature.
> 
> 
> 
> The following is a cut down code sample of the code I'm using. The problem
> I have is that I can read the number of polygons in the feature (i.e. 3
> polygons, nested) using OGR_G_GetGemoetryCount. When I use
> OGR_R_GetGeometryRef to get the handle/pointer for each of the polygons in
> turn I get what appears to be a valid handle but when I use it to get the
> number of points/vertices in the polygon it always returns 0.

Graeme,

You didn't display the WKT that corresponds to the geometry, so I will just 
make the guess that the geometries returned is a multipolygon and not a 
polygon.

So you might need one more level of OGR_G_GetGeometryCount and 
OGR_G_GetGeometryRef to go to the ring level.

Best regards,

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list