Convert a MultiDiGraph to node and/or edge GeoDataFrames.
# OSMnx: New Methods for Acquiring, Constructing, Analyzing, and Visualizing Complex Street Networks
import osmnx as ox
ox.config(use_cache=True, log_console=False)
ox.__version__
'1.1.2'
query = '중구, 서울특별시, 대한민국'
network_type = 'drive' # "all_private", "all", "bike", "drive", "drive_service", "walk"
# Create graph from OSM within the boundaries of some geocodable place(s).
G = ox.graph_from_place(query, network_type=network_type)
# Plot a graph.
fig, ax = ox.plot_graph(G)
/Users/junhyun/.pyenv/versions/3.8.5/envs/openstreetmap/lib/python3.8/site-packages/osmnx/geocoder.py:110: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead. gdf = gdf.append(_geocode_query_to_gdf(q, wr, by_osmid))
# Convert a MultiDiGraph to node and/or edge GeoDataFrames.
gdf = ox.utils_graph.graph_to_gdfs(
G,
nodes=False, # AttributeError: 'tuple' object has no attribute 'head'
edges=True,
node_geometry=True,
fill_edge_geometry=True
)
gdf.head()
osmid | oneway | highway | length | geometry | name | lanes | maxspeed | junction | ref | bridge | tunnel | access | |||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u | v | key | |||||||||||||
300879699 | 436870699 | 0 | 37399712 | False | unclassified | 52.517 | LINESTRING (127.00024 37.55161, 127.00028 37.5... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
414685366 | 7301027934 | 0 | 772527390 | False | residential | 10.713 | LINESTRING (126.99319 37.56110, 126.99320 37.5... | 퇴계로34길 | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
7206358785 | 0 | 219696192 | True | secondary | 117.882 | LINESTRING (126.99319 37.56110, 126.99317 37.5... | 충무로 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | |
2374697789 | 0 | 219696193 | True | secondary | 87.216 | LINESTRING (126.99319 37.56110, 126.99306 37.5... | 퇴계로 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | |
414685371 | 4223315309 | 0 | 333580689 | True | secondary | 53.798 | LINESTRING (126.96754 37.56142, 126.96813 37.5... | 서소문로 | NaN | NaN | NaN | NaN | NaN | NaN | NaN |