python osmnx – extract only big freeways of a country

Yes you can do this with OSMnx:

import osmnx as ox
ox.config(use_cache=True, log_console=True)
G = ox.graph_from_place('France', network_type="drive", custom_filter="["highway"~"motorway"]")
fig, ax = ox.plot_graph(G)

See also this answer if you’d like to filter by multiple highway tag values (e.g., retain all motorways AND primary roads).

Finally, note that as of OSMnx v0.15.0, the gdf_from_place and gdf_from_places functions have been deprecated and replaced by the geocode_to_gdf function. See the docs for details.

Leave a Comment