<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>Hi,</span></div><div><span></span> </div><div><span>You were correct, it is returning multipolygon (9sorry, I should have included that information).</span></div><div><span></span> </div><div><span>I've made the change you suggested so the code looks like</span></div><div><span></span> </div><span><div class="yiv929926719MsoNormal" style="text-indent: 36pt;">Int index = 0;</div><div class="yiv929926719MsoNormal" style="text-indent: 36pt;">OGRGeometryH hGeometry = OGR_F_GetGeometryRef(hFeature);</div><div class="yiv929926719MsoNormal" style="text-indent: 36pt;">int shape_type = wkbFlatten(ORG_G_GetGeometry(hGeometry);</div><div class="yiv929926719MsoNormal" style="text-indent: 36pt;">int num_geom = OGR_G_GetGeometryCount(hGeometry) - 1; // Returns a valid result</div><div class="yiv929926719MsoNormal"
 style="text-indent: 36pt;">int innerIndex = 0;</div><div class="yiv929926719MsoNormal">  </div><div class="yiv929926719MsoNormal" style="text-indent: 36pt;">do</div><div class="yiv929926719MsoNormal" style="text-indent: 36pt;">{</div><div class="yiv929926719MsoNormal" style="text-indent: 36pt;">                OGRGeometryH hRing = OGR_G_GetGeometryRef(hGeometry, index);</div><div class="yiv929926719MsoNormal" style="text-indent: 36pt;">                OGRGeometryH tmpGeo = OGR_G_GetGeometryRef(hRing, innerIndex);</div><div class="yiv929926719MsoNormal" style="text-indent: 36pt;">                Int num_vertices = OGR_G_GetPointCount(tmpGeo); </div><div class="yiv929926719MsoNormal" style="text-indent:
 36pt;">                //.</div><div class="yiv929926719MsoNormal" style="text-indent: 36pt; margin-left: 36pt;">//. Do something with the data</div><div class="yiv929926719MsoNormal" style="text-indent: 36pt; margin-left: 36pt;">//.</div><div class="yiv929926719MsoNormal" style="text-indent: 36pt; margin-left: 36pt;">Index++;</div><div class="yiv929926719MsoNormal" style="text-indent: 36pt;">}</div><div class="yiv929926719MsoNormal" style="text-indent: 36pt;">// Destroy the hfeature here</div><div class="yiv929926719MsoNormal">)</div></span><div> </div><div>If innerIndex is 0 then I can read the data for that polygon. If innerIndex in 1 then tmpGeo is NULL even though there are 2 inner polygons in the test data.</div><div> </div><div>Have I do something stupid ?</div><div> </div><div>The test data is a simple square with 2 squares inside it created using
 shapefile.py</div><div> </div><div>If anybody has a small piece of example could it would be a great help.</div><div> </div><div>Regards</div><div> </div><div>Graeme</div>  <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <div class="hr" style="margin: 5px 0px; padding: 0px; border: 1px solid rgb(204, 204, 204); height: 0px; line-height: 0; font-size: 0px;" contenteditable="false" readonly="true"></div>  <font face="Arial" size="2"> <b><span style="font-weight: bold;">From:</span></b> Even Rouault <even.rouault@spatialys.com><br> <b><span style="font-weight: bold;">To:</span></b> gdal-dev@lists.osgeo.org <br><b><span style="font-weight: bold;">Cc:</span></b> Graeme Wilkie <graeme.wilkie@btinternet.com> <br> <b><span style="font-weight: bold;">Sent:</span></b> Thursday, August 7, 2014 9:26
 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [gdal-dev] GDAL, ESRI Shapefiles and nested polygons<br> </font> </div> <div class="y_msg_container"><br>Le jeudi 07 août 2014 22:20:34, Graeme Wilkie a écrit :<br>> Hi,<br>> <br>> I'm trying to use GDAL to read ESRI shapefiles. I've got it working for<br>> points, lines, polygons, polylines and multipoint but I'm having problems<br>> with polygons that contain polygons in the same feature.<br>> <br>> <br>> <br>> The following is a cut down code sample of the code I'm using. The problem<br>> I have is that I can read the number of polygons in the feature (i.e. 3<br>> polygons, nested) using OGR_G_GetGemoetryCount. When I use<br>> OGR_R_GetGeometryRef to get the handle/pointer for each of the polygons in<br>> turn I get what appears to be a valid handle but when I use it to get the<br>> number of points/vertices in the polygon it always returns
 0.<br><br>Graeme,<br><br>You didn't display the WKT that corresponds to the geometry, so I will just <br>make the guess that the geometries returned is a multipolygon and not a <br>polygon.<br><br>So you might need one more level of OGR_G_GetGeometryCount and <br>OGR_G_GetGeometryRef to go to the ring level.<br><br>Best regards,<br><br>Even<br><br>-- <br>Spatialys - Geospatial professional services<br><a href="http://www.spatialys.com/" target="_blank">http://www.spatialys.com/</a><br><br><br></div> </div> </div>  </div></body></html>