I've got a CSV file with a series of points in each row, point 1, point 2, and point 3. The row also has a series of attributes that I want to be in the attribute table of the resulting feature class (most notably 'id' and 'token'). I can make the polygons ok, but I'm struggling to figure out how to actually get the values into the fields. They're all coming up with default values. I've tried to iterrate back over the resulting shape file to no avail. I'm not sure what tree to even begin barking up at this point. Can anyone point me towards what tree to start barking up?
import arcpy
print "Starting!"
fc = 'c:/temp/test.dbf'
#fields = ['Home_y', 'Home_x', 'Work_y', 'Work_x', 'School_y', 'School_x']
fields = ['Home_x', 'Home_y', 'Work_x', 'Work_y', 'School_x', 'School_y', 'id', 'token']
feature_info = []
features = []
with arcpy.da.SearchCursor(fc, fields) as cursor:
for row in cursor:
feature = []
feature = [[row[0],row[1]],[row[2],row[3]],[row[4],row[5]]]
poly = arcpy.Polygon(arcpy.Array([arcpy.Point(*coords) for coords in feature]),arcpy.SpatialReference(4326))
arcpy.AddField_management(poly,"id","TEXT")
arcpy.AddField_management(poly,"token","TEXT")
#arcpy.CalculateField_management(poly, "id", "Hello_World")
features.append(poly)
print "Writing shape file..."
arcpy.CopyFeatures_management(features, "c:/temp/polygons.shp")
print "Done writing shape file..."