0

I am trying to read polyline from the feature class and then add a point to the geometry and the update it in the same feature class.... I am able to read it and add the new point...but not able to save the geometry?

with arcpy.da.UpdateCursor(near_features, ["objectid","SHAPE@"]) as cursor:
    for row in cursor:
        lnObjid= row[0]
        array = arcpy.Array()
        geom = row[1]
        for part in geom:
            for pnt in part:
                array.append(pnt)
        for ptid,lineid,ptX,ptY in zip(lst_pt_objIds,lst_Ln_objIds,lst_Pt_X,lst_Pt_Y):  
            if lineid == lnObjid:
                new_point = arcpy.Point(ptX,ptY)
                new_array = arcpy.Array([array.getObject(x) for x in range(1,array.count)]+[new_point])
                array = new_array  
        if array.count !=0:
            geom = arcpy.Polyline(array)
            cursor.updateRow([row[0],geom])   
            array.removeAll()

1 Answer 1

1

Replace

geom = arcpy.Polyline(array)

with

geom = arcpy.Polyline(array, spatial_reference)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.