Home > Mobile >  OSMnx I want to get the meter distance of the routes in minutes
OSMnx I want to get the meter distance of the routes in minutes

Time:10-16

Right now I have in meters, how do I convert them to minutes?

                            orig_node = ox.nearest_nodes(G, X=fromLatLng[1], Y=fromLatLng[0])
                            dest_node = ox.nearest_nodes(G, X=toLatLng[1], Y=toLatLng[0])
                            
                            # gets route in meters
                            pathDistance =  nx.shortest_path_length(G, orig_node, dest_node, weight='length')
                            print('pathDistance: ', pathDistance)

Here is an example of what it printed from one of my route distances.

pathDistance: 3192.146999999999


Here are some more information:

I don't know how much 3192.146999999999 Meters are in minutes. It would be hard to know when roads got different speed limits and also traffic lights.

The vehicle type I'm using is Motorcycle or car, but I think I will mostly use Motorcycles, I don't even think I will use car, but maybe I will.

I'm also doing this in Django, so not sure if Django would make this any easier.

CodePudding user response:

Solving shortest paths by free-flow travel time is explained in the docs and the OSMnx usage examples. You can also find examples here on StackOverflow. If you add_edge_speeds and add_edge_travel_times, you can solve shortest paths weighted by travel_time (in seconds).

  • Related