Hello I\'m trying to find the distance to the nearest edge, in meters, using the OSMNx (OpenStreetMap + NetworkX) package. This is my code:
def m
OSMnx's get_nearest_edge
does return the distance. See the docs, which say "Optionally return the distance in graph’s coordinates’ units between the point and the nearest edge." If you don't want to work in degrees as your units, just project your graph:
import osmnx as ox
from shapely.geometry import Point
ox.config(use_cache=True, log_console=True)
# lat-long point
point = 34.081076, -118.351811
G = ox.graph_from_point(point, network_type='drive')
# project the graph (and point) to a meter projection
Gp = ox.project_graph(G)
point_geom_proj, crs = ox.projection.project_geometry(Point(reversed(point)), to_crs=Gp.graph['crs'])
x, y = point_geom_proj.x, point_geom_proj.y
# find nearest edge as (u, v, key) and distance to it
u, v, key, dist = ox.get_nearest_edge(Gp, (y, x), return_dist=True)
dist # 40.2 meters