get_summ_route: Get Summary Route Information

View source: R/get_summ_route.R

get_summ_routeR Documentation

Get Summary Route Information

Description

This function is a wrapper for the Route Service API. It is similar to get_route, except it returns a tibble with only total time and total distance, and also optionally, the start coordinates and end coordinates. If route = "pt", only the best route is chosen (i.e. n_itineraries = 1).

Usage

get_summ_route(
  token,
  start,
  end,
  route,
  date = Sys.Date(),
  time = format(Sys.time(), format = "%T"),
  mode = NULL,
  max_dist = NULL,
  route_geom = FALSE
)

Arguments

token

User's API token. This can be retrieved using get_token

start

Vector of c(lat, lon) coordinates for the route start point

end

Vector of c(lat, lon) coordinates for the route end point

route

Type of route. Accepted values are walk, drive, pt (public transport), or cycle

date

Default = current date. Date for which route is requested.

time

Default = current time. Time for which route is requested.

mode

Required if route = "pt". Accepted values are transit, bus or rail

max_dist

Optional if route = "pt". Maximum walking distance

route_geom

Default = FALSE. Whether to return decoded route_geometry. Please ensure packages googlePolylines and sf are installed and note that this is a lossy conversion.

Value

If no error occurs, a tibble of 1 x 2 with the variables:

total_time

The total time taken for this route

total_dist

The total distance travelled for this route

If an error occurs, the output will be NA, along with a warning message.


onemapsgapi documentation built on Nov. 29, 2022, 9:06 a.m.