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]],
[[1,1],[2,1],[2,2],[1,2],[1,1]],
[[8,8],[9,8],[9,9],[8,9],[8,8]],
[[8,1],[9,1],[9,2],[8,2],[8,1]],
[[1,8],[2,8],[2,9],[1,9],[1,8]]],
[[[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]
array.add(point)
# Create the polygon object
polygon = arcpy.Polygon(array)
# Clear the array for the next feature
array.removeAll()
# Append to the feature list
features.append(polygon)
# Copy the features to an output feature class
arcpy.CopyFeatures_management(features, outputFeatureClass)
if __name__ == '__main__':
main() Please help!
... View more