miketho16

Polygon holes

Discussion created by miketho16 on Nov 1, 2011
Latest reply on Nov 6, 2011 by kimo
Hello,

I believe the code below should identify polygon features that have holes.  However, it doesn't work in all cases.  On certain individual features it fails to find the hole, even though I have verified in ArcMap that the hole exists. On other individual features, even in the same feature class, it succeeds in finding the holes.  I have not been able to determine any material difference between the features on which it works, and those upon which it does not work.  Has anyone seen this before?  Any fix/work around?

import arcgisscripting

gp = arcgisscripting.create(9.3)
fc = "c:/test.mdb/test/Test"
rows = gp.SearchCursor(fc)       
row = rows.Next()
RowIdx = 0
while row:
    feat = row.shape
    parts = feat.GetPart()
    part = parts.Next()
    PartIdx = 0
    while part:
        PointIdx = 0
        pointTemp = part.Next()
        while(pointTemp):
            pointTemp = part.Next()
            if(not pointTemp):
                pointTemp = part.Next()
                PointIdx = PointIdx + 1
                if(pointTemp):
                    print ("Found inner ring:" + fc + "  ObjectID: " + str(row.GetValue("ObjectId")) + "  RowIdx: " + str(RowIdx) + "  PartIdx: " + str(PartIdx) + "  PointIdx: " + str(PointIdx) + "  Point Count: " + str(part.Count) + "  Part Count: " + str(feat.PartCount))
            PointIdx = PointIdx + 1
        part=parts.Next()
        PartIdx = PartIdx + 1
    row = rows.Next()
    RowIdx = RowIdx + 1

Outcomes