Check which edge attributes exist (NetworkX)

丶灬走出姿态 提交于 2019-12-11 05:02:05

问题


I'm using OSMNX to load an OpenStreetMap file of a city into NetworkX. Is there any way for me to see which attributes are stored in the graph? I believe OSMNX might for instance store the length of a street, or the type of road. I want to know what the names of the attributes are that I can access.


回答1:


You could either display the edges to see what's in them:

import osmnx as ox
G = ox.graph_from_place('Piedmont, California', network_type='drive')
print(G.edges(keys=True, data=True))

Or you could use OSMnx to convert the edges to a GeoDataFrame and inspect its columns:

edge_attributes = ox.graph_to_gdfs(G, nodes=False).columns
print(edge_attributes)


来源:https://stackoverflow.com/questions/43830767/check-which-edge-attributes-exist-networkx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!