Title
traveltime -- Find travel time between points using Google Maps
Syntax traveltime, start_x(varname) start_y(varname) end_x(varname) end_y(varname) [mode(varname) km]
Description
traveltime uses Google Maps to generate travel time and calculate distance between sets of points. start_x(), start_y(), end_x(), and end_y() contain the latitude and longitude of the origin and destination points, in decimal degrees. Choice of travel mode can also be specified with the mode() option.
traveltime generates the variables days, hours, mins, and traveltime_dist. The first three variables correspond to the number of days, hours, and minutes it takes to travel between the origin and destination. For example, if the travel time between origin and destination is 1 day, 7 hours, and 37 mins, the values for days, hours, and mins would be 1, 7, and 37, respectively. The variable traveltime_dist is the distance between the sets of points. The traveltime_dist will be reported in miles unless the kilometers (km) option is specified.
Options
start_x(varname) specifies the variable containing the geocoded x coordinate of the starting point. start_x() is required.
start_y(varname) specifies the variable containing the geocoded y coordinate of the starting point. start_y() is required.
end_x(varname) specifies the variable containing the geocoded x coordinate of the destination. end_x() is required.
end_y(varname) specifies the variable containing the geocoded y coordinate of the destination. end_y() is required.
mode(varname) specifies the mode choice of the trip. The values are set to 1 for car, 2 for public transportation, and 3 for walking. The default mode is car.
km specifies that traveltime_dist be reported in kilometers rather than in miles (the default).
Note and warning
traveltime requires that the latitude and longitude of the origin and destination points be in decimal degrees. This task can be accomplished using the geocode command.
Google Maps has a daily limit of maximum queries that is not currently known. If you use traveltime, you should use it in accordance with Google's terms of use. For more information on the terms of service of Google Maps, see http://code.google.com/apis/maps/terms.html.
Example
. traveltime, start_x(begin_long) start_y(begin_lat) end_x(end_long) end_y(end_lat) mode(autochoice)
Authors
Adam Ozimek Econsult Corporation Philadelphia, PA ozimek@econsult.com Daniel Miles Econsult Corporation Philadelphia, PA miles@econsult.com
Also see
Article: Stata Journal, volume 11, number 1: dm0053
Help: geocode (if installed)