Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to find out walking time between to nodes?

Tags:

julia

Is there any option in routing package of graph.jl or osmx.jl or any other routing package to find out the walking time of any edges? Right now inside o f a map when I look at weights map.w is shows a distance while having car? Is that right? how to know the distance or the time it takes to walk from i to j.

like image 774
yaodao vang Avatar asked Jan 17 '26 23:01

yaodao vang


1 Answers

Assume using data from tutorial:

using OpenStreetMapX
map_file_path = joinpath(dirname(pathof(OpenStreetMapX)),"..","test/data/reno_east3.osm")
mx = get_map_data(map_file_path, use_cache=false, trim_to_connected_graph=true);

Normaly an OSM map is build around road classes. For each road class you have some driving speeds:

julia> OpenStreetMapX.SPEED_ROADS_URBAN
Dict{Int64, Float64} with 8 entries:
  5 => 50.0
  4 => 70.0
  6 => 40.0
  7 => 20.0
  2 => 90.0
  8 => 10.0
  3 => 90.0
  1 => 100.0

These are however driving speeds for cars. Let us assume that people walk 5km/h and walking speed does not depend on the road class. Than you can do:

SPEEDS_ROADS_WALK = Dict(1:8 .=> 5.0)

Suppose you want to walk between 2 OSM nodes 1897440773 and 2445740506:

julia> fastest_route(mx, 1897440773, 2445740506,speeds=SPEEDS_ROADS_WALK)
([1897440773, 3149568876, 3149568759, 140328042, 140328045, 140328047, 3149568878, 3149568997, 2445740506], 710.5468521109882, 511.59373351991167)

You can see the distance is 710 meters and the walk takes 511 seconds.

Now let if you want a walking time for each pair of nodes on the map you can do:

julia> walk_times = Dict( mx.e .=>  OpenStreetMapX.network_travel_times(mx, SPEEDS_ROADS_WALK))
Dict{Tuple{Int64, Int64}, Float64} with 3983 entries:
  (140377668, 140377665)           => 63.315
  (140236662, 1895015747190256479) => 16.3884
  (2440185561, 2440185544)         => 87.9369
  (140428209, 140254787)           => 153.809
  (3625693298, 3625693640)         => 65.4547
  (140233521, 140312783)           => 241.643
...

Now walk_times is dictionary that tells how long it takes to walk around the city. You can easily use it with the vector from fastest_route to get times for each pair of nodes during a walk.

This approach is perhaps more useful when you have different speeds for different road classes. Yet as you can see it can be used with walking too.

like image 130
Przemyslaw Szufel Avatar answered Jan 21 '26 09:01

Przemyslaw Szufel