I have some working code using arcpy.InsertCursor
which I want to convert to arcpy.da.InsertCursor
. This I want to do primarily as ESRI claims that da
methods are more optimized. The code I have is follows:
array = arcpy.Array()
point = arcpy.Point()
tie_shp_file = arcpy.env.workspace + "/" + out_name
insert_cursor = arcpy.InsertCursor(tie_shp_file)
feat = insert_cursor.newRow()
for line in all_lines: #all_lines is of the form array([[0, 3],[0, 7],[1, 3]) indicating line [from, to]
#from
point.X=coords_pts[str(pt[line[0]])][0]
point.Y=coords_pts[str(pt[line[0]])][1]
array.add(point)
#to
point.X=coords_pts[str(pt[line[1]])][0]
point.Y=coords_pts[str(pt[line[1]])][1]
array.add(point)
polyline=arcpy.Polyline(array)# Create a Polyline object based on the array of points
array.removeAll() #Clear the array
feat.shape = polyline
insert_cursor.insertRow(feat)
The code inserts lines to a line shapefile. The lines are created by specifying its end points.
How do I convert this? I am specifically stuck on how to pass the to and from points in the new version.