I have a list of thousands coordinates (lat, long). I want to find nearest road and distance to it for each point. I tried to use OSMNX: loaded all roads from osmnx and calculate distance from each point to each road (code is below). But it takes a very long time to compute.
roads = gdf[["geometry", "u", "v","ref","name","highway","lanes"]].values.tolist()
# calculate and attach distance
roads_with_distances = [(road, Point(tuple(reversed((59.961517, 30.340880)))).distance(road[0])) for road in roads] #ox
# sort by distance
roads_with_distances = sorted(roads_with_distances, key=lambda x: x[1])
# Select closest road
closest_road = roads_with_distances[0]
# Check whether you are actually "on" the road
if round(closest_road[1],4) < 0.0001: print('Hit the road, Jack!')
Example of my data (coord column):
Example of OSMNX road data (road==Linestring):
Is there a efficient way to find nearest road and ditance (in metres)? I am looking for a Python method.