My goal is to create a layer of lines representing the closest street segment to a set of points.
The code:
arcpy.SpatialJoin_analysis(
target_features=point_req,
join_features=selected_streets,
out_feature_class=pt_st_join_output,
join_operation='JOIN_ONE_TO_ONE',
join_type='KEEP_COMMON',
match_option='CLOSEST',
distance_field_name='CLOSEST')
Works almost perfectly, doing the join correctly but the geometry included in the table is from the target layer, points, rather than the join layer, lines.
I could use a cursor to run through the points layer and build a layer of lines by finding each row's joined ID in the lines layer. I'm hoping to avoid this out of concerns about runtime since I'd have to loop through the lines layer for each point.
It seems like there should be a more elegant way to do this.