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
294 views
in Technique[技术] by (71.8m points)

The Osmnx python graph_to_gdfs sometimes returns a list in the name column, what's causing this?

I'm using OSmnx to create some nice maps where I color streets based on the name of the street, inspired by puntofisso (eg: if it's a street, it needs to be red, a lane is green, etc). I noticed that sometimes the name of an edge is not a string, but a list instead. I worked around that so far, but is there an argument that could solve this? Or is it caused by something in OpenStreetMap? I was unsuccessful in googling for answers unfortunately.

test_place='Kerkstraat, Delft'
# Create a graph around this address
G3 = ox.graph_from_address(test_place, network_type='all',dist=100, dist_type='bbox')
edge_attributes3 = ox.graph_to_gdfs(G3, nodes=False)
edge_attributes3.head(50)

This gives [Markt, Kerkstraat] in the name column in the row with index 2. My solution now just takes the first element of the list, but I wanted to find the Kerkstraat in Delft and it turns out that the Kerkstraat only occurs in edges that have a list for their name.

Any help is greatly appreciated!

question from:https://stackoverflow.com/questions/65545458/the-osmnx-python-graph-to-gdfs-sometimes-returns-a-list-in-the-name-column-what

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

1 Reply

0 votes
by (71.8m points)

Given the arguments you passed to graph_from_address, you've left the simplify=True default parameterization. Therefore your graph was simplified when created. From the docs on simplification:

Some of the resulting consolidated edges may comprise multiple OSM ways, and if so, their multiple attribute values are stored as a list.


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

...