1

I'm working with recent Census (TIGER) road files in ArcGIS 10.5 / ArcPy (Advanced license). I want to get the road name(s) of the closest road segment (between intersections) to a point. Roads in this dataset frequently have different names which are represented by overlapping lines. The example below is output from Intersect with line output; this type of overlap occurs for a good portion of my dataset.

enter image description here

To get the roads into segments broken by the intersections, I used Unsplit Line then Feature to Line.

Using Near analysis would get me the closest road to specific points, but doesn't reflect the other road names / aliases. I'm looking for something similar to Spatial Join where you can have a combined output field, but Spatial Join requires two input layers. What I've thought to try next are either a) copy the layer and use Spatial Join or b) Use the Near Tool with a maximum of 10 nearest objects and somehow query the table (cursor?) based on NEAR_FID and NEAR_RANK and write the results to a new field. Am I missing any better approaches here?

This question is similar to how to identify cross streets for points that are not at intersections? but I'm looking for all of the names of the road the point is on, not the names of the cross streets.

1

This seems to do the trick. I'm working on scripting it so any suggestions would be welcome.

  1. Unsplit by FULLNAME, RTTYP, MTFCC
  2. Feature to line
  3. Use the Find Identical tool by Shape (thanks BERA) (Use keep only duplicates to reduce processing time)
  4. Loop through the table (Python code below) and output another table (in my code, as CSV) with "matchgroup" and a string of the road names, separated by commas
  5. Join the resulting table back to the IdenticalbyShape table
  6. Join this intermediate table to the feature to line output
  7. Export the resulting layer

from collections import defaultdict
identicaltable = 'splitidentical'
roadfc = "tl_2016_55139_roads_split"
identicaldict = defaultdict(list)
with arcpy.da.SearchCursor(identicaltable, ['IN_FID', 'FEAT_SEQ']) as cursor:
    for row in cursor:
        roadfid = row[0]
        matchgroup = row[1]
        identicaldict[matchgroup].append(roadfid)    
namedidenticaldict = defaultdict(list)
for i in identicaldict:
     print i, identicaldict[i]
     values = identicaldict[i]
     fidlist_str = ["FID = " + str(x) for x in values]
     sqlExp_fids = " OR ".join(fidlist_str)
     with arcpy.da.SearchCursor(roadfc, ['FID', 'FULLNAME'], where_clause = sqlExp_fids) as cursor2:
         templist = []
         for row in cursor2:
             templist.append(row[1])
         names = ", ".join(templist)
         print names
         namedidenticaldict[i] = names

(write to CSV or possibly a table)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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