I have a *.csv file that have a specific field that contain array coordinates representing a route. This is a example:
[(39.72412, -104.9995), (39.72412, -105.00091), (39.72417, -105.00157), (39.72422, -105.00159)]
How can I create with Python a polyline shapefile by this array point coordinate? Open Source or Esri solution is the same. I have try with this code using the help below, and i have add a fix to read specific field by csv:
with open(csvfile,'rb') as f: reader = csv.DictReader(f) for row in reader: listrow=ast.literal_eval(row["route"]) #row will be a string representation of a list so it its converted to a list with ast.literal_eval line=arcpy.Polyline(arcpy.Array([arcpy.Point(*coords) for coords in listrow])) icur.insertRow((line,)) del icur
the code works fine, but i would read a second field of csv to see into shapefile. My csv have for each row the array coordinate and ID, how i can write also the ID in line shape?