Abstract
The community-contributed command
1 Introduction
Weber and Péclat (2017) introduced the community-contributed command
The capabilities of the first version of
The new release of the command presented in this article overcomes several limitations. Important new options have been implemented to let the user specify transport mode, departure time, and various features of the route to be followed. The new version of
2 The updated command
2.1 georoute
The syntax of
{
{
Main (compulsory)
Routing options
The transport mode can be specified either via a string (for instance,
The routing type can be specified either via a string (for instance,
The departure time can be specified either via a string and a mask (for instance,
New variables
Reporting
2.2 georoutei
To facilitate quick requests for single pairs of addresses or geographical coordinates, a command with immediate arguments proves handy. The syntax of
{
2.2.1 Options
Options are as described in section 2.1, except that all arguments must be parsed as strings. 1
2.2.2 Stored results
3 Examples
3.1 Using georoutei
We start our demonstration with the immediate command
Say that we are interested in traveling from the New York Stock Exchange to the Madison Square Garden. We would type the following: 2
We started by storing the addresses in global macros to simplify the code and also to be able to use the same addresses later without having to retype them.
The output indicates that travel distance between these two places is around 4.2 miles, and it could be covered in a bit less than 20 minutes. Said otherwise, the average speed (that could be computed by typing
Because we did not specify anything other than the departure and destination points, all the options were automatically set to their defaults. The first block of output shows the settings and indeed indicates that transport mode was assigned to
In the previous release of the command, none of the default settings could be altered. With this new version, however, we can change, among other options, the transport mode:
We observe that travel distance in this case is a bit shorter with a bicycle than with a car, which is caused by the HERE API considering some roads (such as those located in parks) as open to cyclists but not to cars. Nevertheless, travel time is naturally longer with a bicycle. The output indicates that accounting for departure time would have no impact on the outcome for travel by bicycle. Finally, we see that the fastest travel time is calculated for public transport, with a travel time lower than both car travel and bicycle travel.
Rather than allow the time of departure to be assigned by default (and therefore possibly obtain a different outcome after every run), we can specify the date and time of departure, therefore taking into account historical traffic information:
Here we additionally used option
The last series of options available with
For this trip, we observe that the default settings yield a travel distance of more than 560 kilometers. 3
If we ask the API to look for the shortest distance, by using option
Finally, note that avoiding toll roads, by using option
3.2 Using georoute
The full command,
To show the equivalence between the two commands, we create a small dataset and replicate the calculations of travel distance and travel time between the New York Stock Exchange and the Madison Square Garden:
The results are equivalent to those obtained with
To demonstrate the value added by option

Travel time over the week and for different transport modes
In this example, we use
Travel times (and distances) for all 504 observations of the database are then calculated using a single call to
Figure 1 displays the travel times calculated for each transport mode. We observe that travel time is constant when traveling by bicycle, as expected because this transport mode is not affected by traffic and departure time. 6 There are, however, large variations for traveling by car and by public transport. 7 Travel time by car is longer during the day, especially on weekdays. The pattern is different for public transportation, for which travel time is longer at night when connections are less frequent. We also notice that, on average, travel time is generally shorter with a bicycle than with public transportation, a well-known specificity of the city of Geneva.
4 Caveats
The community-contributed Stata command
5 Conclusion
In this article, we presented the new functionalities available in the updated version of
The
6 Programs and supplemental materials
Supplemental Material, sj-zip-1-stj-10.1177_1536867X221083857 - Travel distance and travel time using Stata: New features and major improvements in georoute
Supplemental Material, sj-zip-1-stj-10.1177_1536867X221083857 for Travel distance and travel time using Stata: New features and major improvements in georoute by Sylvain Weber, Martin Péclat and August Warren in The Stata Journal
Footnotes
6 Programs and supplemental materials
To install a snapshot of the corresponding software files as they existed at the time of publication of this article, type
Notes
References
Supplementary Material
Please find the following supplemental material available below.
For Open Access articles published under a Creative Commons License, all supplemental material carries the same license as the article it is associated with.
For non-Open Access articles published, all supplemental material carries a non-exclusive license, and permission requests for re-use of supplemental material or any part of supplemental material shall be sent directly to the copyright owner as specified in the copyright notice associated with the article.
