AnsweredAssumed Answered

Creating polyline from text file

Question asked by Kinny_K on Feb 12, 2016
Latest reply on Feb 16, 2016 by Dan_Patterson

So I need to create a line based on a series of points. In the example below, there are 4 lines to be created, Line_1. Line_2, etc. Struggling with the loop that creates each pointList.

 

cursor = arcpy.da.InsertCursor(fc, ["Name","SHAPE@"])
   
for ln in inputFile:
  name = ln[0]
  pointList = Point. Array() # initial Array
    ln = line.split(",") # Split the lines in text file
    point = arcpy.Point(ln[1], ln[2]) # Create points 
    pointList.add(point) # Add points to array
        polyline = arcpy.Polyline(pointList)
cursor.insertRow(name, polyline)

 

 

Line_1, 529018.125025, 4108038.05548
Line_1, 529005.718792, 4108028.20659
Line_1, 528993.340503, 4108018.73931
Line_1, 528980.990158, 4108009.65364
Line_1, 528968.667757, 4108000.94958
Line_2, 528956.373301, 4107992.62713
Line_2, 528944.106788, 4107984.68629
Line_2, 528931.86822, 4107977.12705
Line_3, 528919.657595, 4107969.94943
Line_3, 528907.474915, 4107963.15341
Line_3, 528895.320179, 4107956.739
Line_3, 528883.193387, 4107950.7062
Line_4, 528871.09454, 4107945.055
Line_4, 528859.023636, 4107939.78542
Line_4, 528846.980676, 4107934.89744
Line_4, 528834.965661, 4107930.39107

Outcomes