I was having a problem creating certain polygons programmatically, so I put together this simple example to illustrate the issue.The following code works as expected (creates a simple square):
outputFeatureClass = r"c:\temp\test.shp"
coordList = [[0, 0],
[0, -0.01],
[.01, -.01],
[.01, 0],
[0, 0]]
def main():
array = arcpy.Array()
point = arcpy.Point()
# Create a list to store the features
features = []
# Read the coordinates
for coordPair in coordList:
point.X = coordPair[0]
point.Y = coordPair[1]
array.add(point)
polygon = arcpy.Polygon(array)
# Append to the feature list
features.append(polygon)
# Copy the features to an output feature class
arcpy.CopyFeatures_management(features, outputFeatureClass)
if __name__ == '__main__':
import arcpy
arcpy.env.overwriteOutput = True
main()
However, if i change coordList to:
coordList = [[0, 0],
[0, -0.001],
[0.001, -0.001],
[0.001, 0],
[0, 0]]
The script completes successfully, but the resulting geometry is a "null" shape, according to the check geometry tool.My guess is that the vertices are all getting merged at some point? If so, why, and how can i prevent it?Thanks,Dustin