Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
632 views
in Technique[技术] by (71.8m points)

openstreetmap - python osmnx - extract only big freeways of a country

I know it is possible to extract the road network of a city via the OSMNX python package. See details at https://geoffboeing.com/2016/11/osmnx-python-street-networks/ .

paris_network = ox.gdf_from_place("Paris")

But, let's say I do not want that level of high details, but rather only big freeways of a whole country. I'm looking for something like :

france_big_expressway_network = ox.gdf_from_place("France", road_type = "freeway")

I guess it might comes from the "infrastructure" argument but as a newbie I really do not get how to use it precisely.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...