[gdal-dev] Polygon topology

Simon Lyngby Kokkendorff silyko at gmail.com
Tue Mar 8 06:43:52 EST 2011


Thanks a lot. Didn't know that GetGeometryCount did that on polygons :-)

Cheers,
Simon


On Tue, Mar 8, 2011 at 11:51 AM, Even Rouault
<even.rouault at mines-paris.org>wrote:

> Selon Mike Toews <mwtoews at gmail.com>:
>
> > On 8 March 2011 23:22, Even Rouault <even.rouault at mines-paris.org>
> wrote:
> > > Not exactly. In fact you have to use the Geometry.GetGeometryCount()
> that
> > > returns 1 (the exterior ring) + the number of interior rings. So
> > > polygon.GetGeometryCount() - 1 should return the number of interior
> rings
> >
> > I initially thought so too, except that assumption doesn't work for
> > MultiPolygon geometry types.
>
> In that case, you have to first test the geometry type (
> geometry.GetGeometryType() )
>
> If equal to ogr.wkbPolygon, apply the above method.
> If equal to ogr.wkbMultiPolygon, iterate over the polygons with
> geometry.GetGeometryRef(i) the index varying between 0 and
> geometry.GetGeometryCount() (which in that case will be the number of
> polygons).
> For each polygon, apply the above method.
>
> >
> > -Mike
> >
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110308/8f9aa6ab/attachment.html


More information about the gdal-dev mailing list