I want to insert polyline features by another polyline vertices using arcpy. I try to list X and Y coordinates of the source layer then create array from the XY and insert the array to the new feature class. the new feature class has records and length but not show any poyline.I have three segments in the source layer but the result is more than 3 records. I don't know what's the part of my code is wrong ?
# Imports
import arcpy
# Spatial reference of input feature class
SR = arcpy.SpatialReference(4326)
InFc=r"D:\_GIS\VerticesToLine.gdb\Line"
output = r"D:\_GIS\VerticesToLine.gdb\test"
for row in arcpy.da.SearchCursor(InFc, ["OID@", "SHAPE@"]):
print("Feature {}:".format(row[0]))
partnum = 0
vertexArray = arcpy.Array()
for part in row[1]:
for pnt in part:
if pnt:
long = pnt.X
lat = pnt.Y
point = arcpy.Point(long,lat)
print point
vertexArray.add(point)
with arcpy.da.InsertCursor(output, ("SHAPE@",)) as cursor:
polyline = arcpy.Polyline(vertexArray, SR )
cursor.insertRow((polyline,))
partnum += 1