I have a polyline feature class of about 4000 street centerline segments for which I would like to add data on what streets the segments intersect with.
I would like to add some new fields to my dataset that capture information on what street the polyline segment begins at and what street the polyline segment ends at (essentially the intersections)
What I have so far:
I wrote a quick Python script to calculate these values by doing Select By Location -> Boundary Touches:
# Import arcpy and set path to data import arcpy arcpy.env.workspace = "c:\Users\me\Documents\ArcGIS\Default.gdb" #create a master search layer to encompass all streets. searchLayer = arcpy.MakeFeatureLayer_management('StreetsCP', 'searchLayer') #set the fields that we are going to be updating fields = ('FULL_NAME', 'OBJECTID', 'StreetFrom', 'StreetTo') #create a cursor to encompass all rows in streets with arcpy.da.UpdateCursor('StreetsCP', fields) as uCursor: #loop over every row in streets for uRow in uCursor: #set where clause to create a feature layer from the row whereClause = '"OBJECTID" = ' + str(uRow) #create feature layer consisting of just the row we are on inputLayer = arcpy.MakeFeatureLayer_management('StreetsCP', 'inputLayer', whereClause) #select the streets that touch the boundary of the street we are on arcpy.SelectLayerByLocation_management(searchLayer, "BOUNDARY_TOUCHES", inputLayer, "", "NEW_SELECTION") touchingStreets =  uniqueStreets =  #populate the unique streets list with arcpy.da.SearchCursor(searchLayer, 'FULL_NAME') as sCursor: for sRow in sCursor: if sRow != uRow: touchingStreets.append(sRow) #eliminate duplicate street values uniqueStreets = list(set(touchingStreets)) if len(uniqueStreets) <= 2: i = 2 for street in uniqueStreets: uRow[i] = street i += 1 uCursor.updateRow(uRow) arcpy.Delete_management("inputLayer")
The issue I am running into is the directionality of the street. In my street data I have address directionality using Left From/Left To/Right From/Right To, like in the below table:
The Street From and Street To should reflect this same directionality. What are some ideas for capturing the directionality of the street?
Some ideas I've been exploring:
Is there something exposed through ArcObjects that stores the endpoint and beginning point of a polyline using these metrics that I can use to select by location?
Can I somehow determine the directionality just in ArcPy?
As a last resort, Network Analyst might be able to offer me this functionality, but due to not having used Network Analyst before the ramp up time may be too much for my purposes.
If there is functionality that may help me in GRASS/QGIS I'd be willing to explore that as well.
I also have an "intersections" point file that could be used.