Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Travel time between two location

    Hello, I would like to calculate the travel time and distance between two locations. I have the latitude and longitude for both locations. I am using the 'mqtime ' command of Stata for this purpose.

    Before using the 'mqtime' command, I have installed all the necessary packages by following the instructions provided in the 'help mqtime' command.

    To provide you with the latitude and longitude information of the starting and ending locations, I have used the 'dataex' command.

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double(Start_longitude Start_latitude End_longitude End_latitude)
    5.062018999999999 61.3467485   9.65035 65.37965
    5.062018999999999 61.3467485   9.65035 65.37965
            5.0893297 60.4618726    48.125  70.9375
            5.0893297 60.4618726 -13.41665 53.50346
            5.0893297 60.4618726 -12.91464 65.52053
    end


    Here is the command I used:

    mqtime, start_x(Start_longitude) start_y(Start_latitude) end_x(End_longitude) end_y(End_latitude)

    However, I encountered an issue where both the generated travel time and distance values are missing.
    below using dataex- I provide you with what the travel time and travel distance look like.





    ------------------ copy up to and including the previous line ------------------

    Listed 5 out of 5 observations

    --------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double(Start_longitude Start_latitude End_longitude End_latitude) float(travel_time distance fuelUsed) str9 service
    5.062018999999999 61.3467485   9.65035 65.37965 . . . "HERE Maps"
    5.062018999999999 61.3467485   9.65035 65.37965 . . . "HERE Maps"
            5.0893297 60.4618726    48.125  70.9375 . . . "HERE Maps"
            5.0893297 60.4618726 -13.41665 53.50346 . . . "HERE Maps"
            5.0893297 60.4618726 -12.91464 65.52053 . . . "HERE Maps"
    end
    ------------------ copy up to and including the previous line ------------------

    Listed 5 out of 5 observations





    My main issue is how to find "travel time". I managed to find distance using geodist command. However, the only means I have gotten to calculate travel time so far is "mqtime" command.

    Could you please advise me on how to resolve this issue? I would greatly appreciate your assistance. Especially on how I can find travel time using the latitude and longitude information of two different locations. Thank you!"
    Last edited by tig som; 04 Jul 2023, 10:14.

  • #2
    mqtime is from the Stata Journal, as you are asked to explain (FAQ Advice #12). You need to send an email to the authors of the command. Such commands typically query an API. This request is usually sent using HTTP (Hypertext Transfer Protocol). The API then processes the request and returns a response containing the requested data. If the API address changes, then this breaks the program (which may or may not be the problem here).

    Comment


    • #3
      Thank you very much, Andrew Musau!! I discovered that the use of "osrmtime" is no longer relevant based on the Weber and Peclat (2017) article. While searching for an alternative, I came across another recent STATA journal command called "georoute," which can be used to calculate travel time. However, it also requires a Here app developer account and an associated API key. I have reached out to the author of the article to inquire about obtaining the API key and I am awaiting their assistance.

      In the meantime, if there are any other methods available to calculate travel time between two locations, specifically when I have latitude and longitude information of the two locations, I would greatly appreciate knowing about them. Thank you very much in advance !!

      Comment


      • #4
        If you have a reasonable number of coordinates, you can use Google Maps: https://www.google.com/maps/dir///. Google Maps requires you to enter the coordinates as "latitude, longitude". However, looking at your example, the coordinates "65.37965,+9.65035" in observation #1 refer to a point in the Norwegian Sea. Google Maps provides directions and travel times for driving, public transit, walking, ride sharing, cycling, (commercial) flight, or motorcycle. None of these modes of transportation will get you to that position in the Norwegian Sea. Therefore, it is challenging to calculate the travel time for coordinates outside the scope of these transportation options.
        Last edited by Andrew Musau; 05 Jul 2023, 14:46.

        Comment


        • #5
          Thank you, Andrew Musau!!

          Comment

          Working...
          X