[gdal-dev] Polygon topology

Even Rouault even.rouault at mines-paris.org
Tue Mar 8 05:51:08 EST 2011


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
>




More information about the gdal-dev mailing list