Announcement

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

  • New package georoute on SSC

    Dear all,

    Thanks to Kit Baum, a new package georoute is now available for download from SSC. In Stata, type ssc install georoute to install it.
    The georoute package allows to compute travel distance and travel time between two points defined by their addresses or their geographical coordinates. The package contains a "full command" georoute, an immediate command georoutei, and their accompanying help file.
    The purpose of the package is similar to that of existing commands such as traveltime, traveltime3, mqtime, and osrmtime. The first 3 commands are however deprecated, while osrmtime only allows the user to start from geographical coordinates. georoute should thus be useful to researchers who want to compute travel distance between pairs of addresses.

    Best wishes,

    Sylvain

    georoute calculates the georouting distance between two
    addresses or two geographical points identified by their
    coordinates. It uses the HERE API (see
    https://developer.here.com) to retrieve distances in two steps.
    In the first step, addresses are geocoded and their geographical
    coordinates (latitude and longitude) are obtained. In the second
    step, the georouting distance between the two points is obtained.
    The user can also directly provide geographical coordinates,
    which will bypass the first step.

    KW: geography
    KW: distance
    KW: travel time
    KW: geocoding

    Requires: Stata version 11 and insheetjson, libjson from SSC (q.v.)

    Distribution-Date: 20161101

    Author: Sylvain Weber, University of Neuchâtel, Institute of Economic Research
    Support: email [email protected]

    Author: Martin Péclat, University of Neuchâtel, Institute of Economic Research
    Support: email [email protected]


  • #2
    Are these distances as the crow flies, or more google maps-style?

    Comment


    • #3
      Hi Jesse,

      Thanks for your question. The distances computed by georoute are travel distances, i.e. how much you would have to drive to go from point A to point B (or if you prefer google maps-style, but note that the API used by georoute is the HERE API and not the Google API).
      Geodetic (straight line) distances could be obtained by a command such as geodist (from SSC). You can compare the outcome of these two commands for example as follows:
      Code:
      clear
      input str30 place1 str30 place2
      "Paris, France" "Berlin, Germany"
      "Rome, Italy" "Moscow, Russia"
      end
      georoute, hereid(INSERT_YOUR_APP_ID) herecode(INSERT_YOUR_APP_CODE) startad(place1) endad(place2) km coordinates(place1 place2)
      geodist place1_x place1_y place2_x place2_y, gen(linear_distance)
      l place1 place2 travel_distance linear_distance
      You can then check that travel distance is different from (and obviously larger than) geodetic distance in any case.
      I hope this helps.

      Best,

      Sylvain

      Comment


      • #4
        Wow, that's quite frankly amazing! I've often thought it'd be useful to such travel distance exercises, but always stayed away from it because it'd be extremely time consuming.

        Comment


        • #5
          Hello Sylvain,

          Thank you and Martin for this command! I have questions about the use of and your experiences with the HERE account:
          1. What happens (or what have you done) after the 90-day trial period? On HERE's developer site, it looks like there's a basic developer account allowing 15K requests / month; can pay for an account with more monthly requests.
          2. How does HERE define (or calculate) "normal traffic conditions"?
          3. Any idea if the HERE API will be changed in the near future?
          Best, Patrick

          Comment


          • #6
            Dear Patrick,

            Thank you for your questions and sorry for the late reply.
            1. In our experience, it is possible to reactivate a new 90-day free trial once it expires, using the same HERE account. But if you choose to subscribe to any other HERE plan, the command should also work.
            2. Concerning the "normal traffic conditions", we cannot say much more than this I believe. The related HERE documentation is here : https://developer.here.com/documenta...e-summary.html. The attribute in question is "BaseTime". When we wrote “under normal traffic conditions”, we simply wanted to be intuitive. There is no exact way to formulate that I think.
            3. georoute is indeed vulnerable to change in the HERE API, and we cannot guarantee that it will still work in the future. I’m not sure if this is reassuring or not, but georoute is now working since nearly two years.
            I hope this helps.
            Best,
            Martin

            Comment


            • #7
              Dear all,

              Right now, I am having a problem when I run the command georoute. It does not work, generating the following message: <istmt>: 3499 libjson not found r(3499);
              Even when I installed libjson, georoute is still not working, presenting the same error message.
              How can I solve this problem?

              Thank you for your help.
              Best regards,
              Cristian

              Comment


              • #8
                Dear Cristian,

                It's a bit difficult to guess what happened with the information you provide.
                Have you installed both -libjson- and -insheetjson- as requested by -georoute-? It's certainly worth to update these two packages anyway:
                Code:
                ssc install insheetjson, replace
                ssc install libjson, replace
                and then retry to run -georoute-.

                Best,

                Sylvain

                Comment


                • #9
                  hi Sylvain,

                  I'm having some trouble with the HERE API. Is it working for you still? I registered for an account and generated both a javascript and a REST ID and code, and neither will work with georoute! I keep getting the Stata message "There seems so be a problem with your HERE account". Am I missing something obvious? Thanks so much, I'm very confused.

                  Comment


                  • #10
                    Dear Greg, Dear all,

                    Sorry for this. It indeed happens that access to HERE' API services changed and this is affecting georoute.
                    The information provided by HERE is as follows:
                    App ID and App Code have been replaced. We encourage all users to switch to API Key or OAuth 2.0 (JSON Web Tokens) authentication. Please be aware that as part of adapting to the new authentication method, some endpoints have also changed. Please read the documentation about authentication for details.

                    Existing application credentials may still be used with HERE Location Services REST APIs and older versions of the HERE Maps API for JavaScript.
                    So, for HERE applications created before the change, APP ID and APP CODE are still available and can still be used. But for new applications, this is apparently not possible.
                    We will work on a revision of georoute asap to accommodate the changes. Sorry again.

                    Best regards,

                    Sylvain

                    Comment


                    • #11
                      Thank you so much Sylvain! I'm glad to know I wasn't overlooking an obvious error. Best of luck!

                      Comment


                      • #12
                        Dear all,

                        Thanks again for your comments.
                        We have now updated georoute to accommodate the changes in HERE accounts. The new version 2.5 is available from SSC.
                        In the new version, HERE credentials can be specified in either of two ways:
                        1. Like before with old HERE accounts using options hereid(APP ID) and herecode(APP CODE)
                        2. For new HERE accounts (use the REST account), using the new option herekey(API KEY)
                        Hopefully, this will correctly solve all the above-mentioned issues.
                        Best regards,

                        Sylvain

                        Comment


                        • #13
                          Hi Sylvain Weber ,

                          Thank you so much for this command! It's working great for me so far. I have two questions for you:
                          1. I'm using these to calculate distances for rural India. Do you have any sense of how comprehensive the route maps HERE has are? Should they be good for such settings? I'm seeing slightly different results if I just manually type in a few coordinates on Google Maps, so wondering what to make of that.
                          2. What's the limit to how many pairs of places I could use this for in a given day/ month? I just made my account so maybe I'm on some sort of trial account.
                          3. Finally, when you say travel time, is that travel time in car or walking or cycle?

                          Thank you!
                          Last edited by Mansi Jain; 09 Apr 2020, 05:50.

                          Comment


                          • #14
                            Hi Mansi,

                            Thanks for your message.
                            1. I have no idea about the precision of distances calculated with HERE vs Google Maps in India. According to our checks based on US and Europe when preparing the command, the distances were pretty close.
                            2. The number of requests you can make depends on your HERE account. With the Freemium account, you can currently make 250k requests per month (https://developer.here.com/pricing).
                            3. Yes, travel time (and distance) are calculated for cars (see https://www.stata-journal.com/articl...article=dm0092)

                            I hope this helps.

                            Best,

                            Sylvain

                            Comment


                            • #15
                              Hi Sylvain,

                              many thanks for the georoute command!

                              I've been using geocode to calculate the travel distance and travel time between 745 pairs of addresses (745 rows). The command works perfectly when I apply it to a small bunch of the data, i.e observation 1-200. However, when I try to run the georoute command for all the data (all 745 address pairs) I get the following error message:


                              no room to add more variables because of width
                              Width refers to the number of bytes required to store a single observation; it is
                              the sum of the widths of the individual variables. The maximum width allowed is
                              1,048,576 bytes. You just attempted to exceed that.
                              r(902);



                              How can that be? Is there not enough memory on Stata to run the code through all of the observations?
                              I'm currently using Stata/MP 16.0. I tried using compress on my original dataset but no changes were made. Could you maybe tell me, what the problem could be and if it has anything to do witht he georoute command?

                              Many thanks in advance!

                              Helen

                              Comment

                              Working...
                              X