0

I'm trying to extract the type of road from a coordinate (lat& lon). I've found the package osmnx to get some useful data, however, it gives me information from an area instead of a given position (the exact coordinates). This is my code:

pip install rtree
pip install osmnx 
import osmnx as ox
lat = 48.317742784417334
lon = 3.008515725218768
dist = 12
G = ox.graph_from_point(point, dist=dist, network_type='drive', simplify=False) 

gdf = ox.graph_to_gdfs(G, nodes=False, fill_edge_geometry=True)
roads = gdf[["geometry","highway"]].values.tolist()
roads

The result is:

[[<shapely.geometry.linestring.LineString at 0x7f29bb848750>, 'residential'],
 [<shapely.geometry.linestring.LineString at 0x7f29bb848bd0>, 'residential']]

If a reduce the dist value I get an error since no bounders are detected. Is there any other approach? I know that Google Maps integrates an API where you can get such information, however, I want it open source.

0

Your Answer

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