AnsweredAssumed Answered

Update Cursor Help. To Iterate through line segments and get a count of points surrounding each segment.

Question asked by on May 30, 2019
Latest reply on May 30, 2019 by bixb0012

I have a series of line segments that I would like to use to find the count of points within 200 meters of each segment. Im having issues with the loop i have generated and I feel stumped on this one...


ClassLoc_Events_Lyr = arcpy.MakeFeatureLayer_management(ClassLoc_Events_Sort, "ClassLoc_Events_Lyr")
Point_ClassLoc_FC_Lyr = arcpy.MakeFeatureLayer_management(Poly_ClassLoc_FC, "Point_ClassLoc_FC_Lyr")

with arcpy.da.UpdateCursor(ClassLoc_Events_Lyr, ["OID@", "DWELLINGS_COUNT"]) as ClassLoc_Segments:
     for Segment in ClassLoc_Segments:
          Seg = arcpy.SelectLayerByAttribute_management(ClassLoc_Events_Lyr, "NEW_SELECTION", "OBJECTID = {}".format(Segment[0]))
          Sel = arcpy.SelectLayerByLocation_management(Point_ClassLoc_FC_Lyr, "WITHIN_A_DISTANCE", Seg, "200 Meters", "NEW_SELECTION")
          Out = arcpy.MakeFeatureLayer_management(Sel, "ID_Points_Lyr")
          Point_Count = arcpy.GetCount_management(Out)
          Segment.setValue("DWELLINGS_COUNT", Point_Count)

So the loop is supposed to update the line segments. First supposed to select the first row. Next it should then search within 200 meters of the selected row and make a new selection including only the points within the proximity. Then it makes a a seperate feature layer out of the selection in order to do the next step. Next step is to get a count of the selected points. Then it is supposed to update the row "DWELLINGS_COUNT" with the counted points. Finally the loop goes to the next row and the process repeats.


Getting an error on line 10:

AttributeError: 'list' object has no attribute 'setValue'