Bug?: Creating polygons with holes using Arcpy

Discussion created by lukewrogers on Dec 8, 2010
Latest reply on Sep 13, 2013 by curtvprice
I believe I have found what is a bug with the Arcpy site package and how it handles creating polygon geometries...

We are trying to generate polygon geometries using the Arcpy site package and cannot generate polygons with multiple holes. One or two holes in a polygon outer ring seem to work fine but any more than that and the polygon generation fails. In looking at the point arrays that come from an existing multiple hole polygon (using polygon.GetPart()) there is a "None" type object in the point array that indicates that subsequent points are part of a hole. However the arcpy.Array object does not allow the inserting of "None" types or null Points so it appears that holes cannot be created directly and must be inferred by the Arcpy package to create the holes.

Have a look at the attached code and see if you can make it work. The documentation has nothing about this anywhere I can find (other than this) so I have been working backwards to figure it out. The example coordinate list in the attached python file has clockwise outer rings and counter clockwise holes yet still it does not work. The output should look like this (2 polygons):

but instead looks like this:

Here is the code (in case attachment doesn't work):

import arcpy

# Globals
outputFeatureClass = r"D:\temp\geometry\example.mdb\example"
coordList = [[[[0,0],[0,10],[10,10],[10,0],[0,0]],
            [[[10,10], [11,11], [12,10], [10,10]]]]

def main():
    array = arcpy.Array()
    point = arcpy.Point()
    # Create a list to store the features
    features = []
    # Read the coordinates
    for feature in coordList:
        for part in feature:
            for coordPair in part:
                point.X = coordPair[0]
                point.Y = coordPair[1]

        # Create the polygon object
        polygon = arcpy.Polygon(array)
        # Clear the array for the next feature
        # Append to the feature list

    # Copy the features to an output feature class
    arcpy.CopyFeatures_management(features, outputFeatureClass)

if __name__ == '__main__':
Please help!