Returns bus positions for the given route, with an optional search radius. If no parameters are specified, all bus positions are returned.
bus_position(
RouteId = NULL,
Lat = NULL,
Lon = NULL,
Radius = NULL,
api_key = wmata_key()
)
A data frame with 1 row per bus and 13 variables:
Unique identifier for the bus. This is usually visible on the bus itself.
Last reported Latitude of the bus.
Last reported Longitude of the bus.
Distance (meters) of the bus from the provided search
coordinates. Calculated using geodist::geodist()
and the "cheap ruler"
method.
Deviation, in minutes, from schedule. Positive values indicate that the bus is running late while negative ones are for buses running ahead of schedule.
Date and time (UTC) of last position update.
Unique trip ID. This can be correlated with the data returned from the schedule-related methods.
Base route name as shown on the bus. Note that the base route name could also refer to any variant, so a RouteID of 10A could refer to 10A, 10Av1, 10Av2, etc.
General direction of the trip, not the bus itself (e.g.: NORTH, SOUTH, EAST, WEST).
Destination of the bus.
Scheduled start date and time (UTC) of the bus's current trip.
Scheduled end date and time (UTC) of the bus's current trip.
Base bus route, e.g.: 70, 10A.
Center point Latitude, required if Longitude and Radius are specified.
Center point Longitude, required if Latitude and Radius are specified.
Radius (meters) to include in the search area. If NULL
(default) when Lat
and Lon
are supplied, a generic max of 50 kilometers
is used.
Subscription key which provides access to this API. Defaults
Sys.getenv("WMATA_KEY")
via wmata_key()
.
Data frame containing bus position information.
Note that the RouteID
parameter accepts only base route names and no
variations, i.e.: use 10A instead of 10Av1 or 10Av2.
Other Bus Route and Stop Methods:
bus_departs()
,
bus_path()
,
bus_routes()
,
bus_schedule()
,
bus_stops()
if (FALSE) {
bus_position("70", 38.8895, -77.0353)
}