I have two shapefiles, one is polyline, one is points. I use points to split the polyline. How to record the FID of splited points(two end points each line) in the field of polyline.

First I use split tool

then I execute the following code to update the attribute table of polyline

import arcpy
from arcpy import env
env.overwriteOutput = True
sj = r"in_memory\sj"

inPL = r"Y:\Desktop\road\highway.shp"
arcpy.MakeFeatureLayer_management(inPoints, "city_points")
arcpy.MakeFeatureLayer_management(inPL, "road")

for i in range(0,500):
    expr = " [FID] =" + str(i)

    arcpy.SelectLayerByAttribute_management(inPL, "NEW_SELECTION", expr)
    arcpy.SpatialJoin_analysis(inPL, inPoints,sj,"JOIN_ONE_TO_ONE","KEEP_COMMON")

    ## update the attribute table of road, recording the FID of the city in the attribute table of the road 
  • 1
    Welcome to GIS SE! As a new user please take the tour to learn about our focused Q&A format. How have you split the line? How many lines have you got? You could edit the line and type in an ID if you've only got one or two. That said, I see you have tagged arcpy - a question asking for help writing code should include a snippet of the code you've already tried, and details of what happens when you try it.
    – Midavalo
    May 27 '17 at 4:08
  • 1
    You can edit your question to add your code snippet and any other details that may be useful to potential answerers. Include as much information as possible to describe the problem and what you've tried to solve it.
    – Midavalo
    May 27 '17 at 4:10
  • 2

Browse other questions tagged or ask your own question.