I have a point given by lat and lon and I want to find the nearest edge to the point by minimum Euclidean distance. For example
import osmnx as ox
track = [(40.7052, -74.0069)]
fig, ax = ox.plot_graph(G, show=False, close=False)
for pairs in track:
ax.scatter(pairs[1], pairs[0], c='red')
plt.show()
ox.distance.get_nearest_edge(G, track, return_geom=True, return_dist=True)
and I get
(2350521192,2350521202,0,
<shapely.geometry.linestring.LineString at 0x16569aa30>,
162.22242578930698)
It outputs the vertices of the edge and its geometry. The distance between the point and nearest edge is 162. But how do I find the the projection of my point onto this nearest edge?
Here's a complete minimal working example: