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()
)

Arguments

RouteId

Base bus route, e.g.: 70, 10A.

Lat

Center point Latitude, required if Longitude and Radius are specified.

Lon

Center point Longitude, required if Latitude and Radius are specified.

Radius

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.

api_key

Subscription key which provides access to this API. Defaults Sys.getenv("WMATA_KEY") via wmata_key().

Format

A data frame with 1 row per bus and 13 variables:

VehicleID

Unique identifier for the bus. This is usually visible on the bus itself.

Lat

Last reported Latitude of the bus.

Lon

Last reported Longitude of the bus.

Distance

Distance (meters) of the bus from the provided search coordinates. Calculated using geodist::geodist() and the "cheap ruler" method.

Deviation

Deviation, in minutes, from schedule. Positive values indicate that the bus is running late while negative ones are for buses running ahead of schedule.

DateTime

Date and time (UTC) of last position update.

TripID

Unique trip ID. This can be correlated with the data returned from the schedule-related methods.

RouteID

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.

DirectionText

General direction of the trip, not the bus itself (e.g.: NORTH, SOUTH, EAST, WEST).

TripHeadsign

Destination of the bus.

TripStartTime

Scheduled start date and time (UTC) of the bus's current trip.

TripEndTime

Scheduled end date and time (UTC) of the bus's current trip.

BlockNumber

Value

Data frame containing bus position information.

Details

Note that the RouteID parameter accepts only base route names and no variations, i.e.: use 10A instead of 10Av1 or 10Av2.

See also

Examples

if (FALSE) { bus_position("70", 38.8895, -77.0353) }