AnsweredAssumed Answered

arcpy.polyline not creating line

Question asked by wikgrebc on Jul 27, 2020
Latest reply on Jul 28, 2020 by wikgrebc

I'm going crazy and hoping someone can help.  I'm trying to bring in a point feature class, go row by row (using a .da.searchcursor), add two points into an array, and create a polyline from them. Then use an da.update cursor to add that line segment into a line feature class.  Then go to the next row and do the same until I have made a number of line segments from the point features.  I have tried this a ton of different ways, all with the same result, an updated line feature class that has the added rows, but NO lines draw and the length field for all segments are 0.  I've altered this to just run the points and add the points to a new point feature and that works just fine.  This code has also been updated to incorporate the .da.cursors (I have similar code running off the old cursors that work, i'm just trying to update it and the .polyline is not working right).  Does anyone have any ideas or things to try?  I'm going crazy. TIA!


import arcpy

# Set environments / workspace. Workspace will be a parameter in tool.  This parameter should point to a gdb that has all the effort point feature classes
arcpy.env.workspace = r"C:\Users\bhodge\Dropbox (New England Aquarium)\MonumentsWork\MonumentSpeciesDiversity\DataProcessing\MichelleCData.gdb"
arcpy.env.overwriteOutput = True
# input point fc
fc = r"C:\Users\bhodge\Dropbox (New England Aquarium)\MonumentsWork\MonumentSpeciesDiversity\DataProcessing\MichelleCData.gdb\SurveyPointsUTM19_TestSet_Short_6"

arcpy.MakeFeatureLayer_management(fc, "fc_lyr")

# Sort the table by fileid and eventno and create a new fc called fc_sort
sort_fields = [["FILEID", "ASCENDING"], ["EVENTNO", "ASCENDING"]]
fc_Sorted = arcpy.Sort_management("fc_lyr", "fc_sort", sort_fields)

# Create the search cursor
fields = ["SHAPE@"]
with arcpy.da.SearchCursor(fc_Sorted, fields) as cur:
    for row in cur:
        geom1 = row[0].getPart()
        geom2 = row[0].getPart()
        array = arcpy.Array()
        polyline = arcpy.Polyline(array, arcpy.SpatialReference(26919))
        with arcpy.da.InsertCursor(r"C:\Users\bhodge\Dropbox (New England Aquarium)\MonumentsWork\MonumentSpeciesDiversity\DataProcessing\MichelleCData.gdb\OnEffortLinesTEST", 'SHAPE@') as insertCursor:
        del insertCursor
del cur

The result is all the points used draw and are correct (the fc_Sorted /fc_sort), and the line feature class seems to updated in that rows are added, but no lines draw and the Length field is 0.