pyonono

Accessing MULTI-part polygons in arcpy

Discussion created by pyonono on May 30, 2014
Latest reply on Jun 2, 2014 by eibenm
By running this piece of code:

import arcpy
arcpy.env.workspace = "C:\working\GEODATABASES\\tests.gdb"
fcList = arcpy.ListFeatureClasses()
for fc in fcList:
    with arcpy.da.SearchCursor(fc, ("OID@", "SHAPE@")) as cursor:
    for row in cursor:
        print("Feature {0}".format(row[0]))
        print "   " + str(row[1].partCount) + " parts for THIS PARTICULAR FEATURE"
        for part in row[1]:
            poly = arcpy.Polygon(part)
            print("   Points {0}".format(poly.pointCount))  


In theory I am able to list all polygons for a particular feature class and list whether they are multi-part polygons or not. In addition, it shows the number of points per feature part. This is the target.

HOWEVER, it does not do the job properly as I am dealing with a complicate feature class -I think- that actually have more feature parts than the script can identify and have more points per feature part than the script can identify. So, occasionally, it does not obtain the right number of points per part. I know that these points exist because I can see them by visualizing the layer in ArcMap.

By using the OLD reading cursor system in arcpy (not the above one), I get in some polygons a higher number of points, but still there are some of them missing, therefore the script cannot list them.

Why is that this script stops counting either points or parts sometimes when entering a multipart-polygon within my feature class?

Is it my code not well tuned for complicated multi-part polygons?

Thanks,

Outcomes