OSMnx- why is the 'walk' network larger than 'all' network?

833 Views Asked by At

I export and compare the km length of the total network and then the pedestrian network via OSMnx. The strange thing is that for some cities the walk network is larger than the total network. How can this be explained? I checked the queries in the custom filter of the OSMnx code and I still can't explain it, since network='walk' is a stricter definition, thus should be contained in the all network...

Try out this code and let me know if you have any explanations.

place = 'Empire state building, New York, NY 10001, USA'

# import graph all
G_a = ox.graph_from_address(place, retain_all=True, network_type='all', simplify=True, clean_periphery=False)

# import graph walk 
G_w = ox.graph_from_address(place, retain_all=True, network_type='walk', simplify=True, clean_periphery=False) 


print('all: ', G_a.size(weight='length'), 'walk: ', G_w.size(weight='length'))
1

There are 1 best solutions below

2
On BEST ANSWER

The walk network type is fully bidirectional, meaning that each pair of adjacent nodes has at least two edges between them (there could be more than two if the nodes are directly linked by multiple street segments, as this is a MultiDiGraph), one pointing from node u to v and the other pointing from node v to u. Pedestrians can walk either direction on any street, so all edges must be bidirectional in a walking network.

The all network type is not fully bidirectional as it makes no presumptions about who or what may flow through it. Hence, all of its edges obey one-way directionality constraints when present, meaning that some of its nodes may only be linked by a single one-way edge.

This is why you may see more edges in a walk network's model than in an all network's model. However, your all network will always have at least as many nodes as your walk network, as you can see here:

import osmnx as ox
ox.config(use_cache=True, log_console=True)

place = 'Empire state building, New York, NY 10001, USA'
G_a = ox.graph_from_address(place, retain_all=True, network_type='all', 
                            simplify=True, clean_periphery=False)
G_w = ox.graph_from_address(place, retain_all=True, network_type='walk', 
                            simplify=True, clean_periphery=False)
assert len(G_a) >= len(G_w)

You can also see and set which network_type arguments are treating as bidirectional with the bidirectional_network_types setting:

print(ox.settings.bidirectional_network_types)

The bidirectional_network_types setting will be exposed via ox.config() in the next release of OSMnx.