Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm having problems creating the last line from a list of coordinates that I have. I have a text file with coordinate data with a X, Y, and a Line ID (LID). I read the file and inserted each attribute into a coordsList[]. CoordsList has 234 coordinates with an [LID, X, Y] here is my code looping through the list and inserting each set of coordinates for one line into the feature class.

lineCursor = arcpy.da.InsertCursor(lineFC, ["SHAPE@"])


id = -1 #id to identify if which points go to which lines
for coords in coordsList:
    if id == -1:
        id = coords[0]

    if id != coords[0]:
        lineCursor.insertRow([arcpy.Polyline(lineArray)])
        lineArray.removeAll()
    lineArray.add(arcpy.Point(coords[1], coords[2], ID=coords[0]))
    id = coords[0]

lineCursor.insertRow([arcpy.Polyline(lineArray)])

del lineCursor

What am I missing? The feature class is populated correctly until the last line. Then only one of the coordinates is capture so lineArray doesn't contain two coordinates to create the line. There is a record with no geometry? Any direction would be much appreciated.

share|improve this question
    
In the help for arcpy.Point, under Properties, it mentions that ID must be a unique integer. Could that be the problem? Also, where are you initializing lineArray? –  Paul Jul 14 '13 at 19:54
    
Thanks for the tip on the ID, but it didn't change anything. I actually initialize the array prior to creating the InsertCursor I just forgot to paste that at the top. I ended up running this code on a different machine and it worked! I don't know what was going on. –  bighill Jul 24 '13 at 16:46
    
ArcMap exhibits strange properties some times. It's great to have the luxury of running of a different machine. –  Paul Jul 24 '13 at 17:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.