This function returns isochrones from the Mapbox Navigation Service Isochrone API. Isochrones are shapes that represent the reachable area around one or more locations within a given travel time. Isochrones can be computed for driving, walking, or cycling routing profiles, and can optionally be set to return distances rather than times. mb_isochrone() returns isochrones as simple features objects in the WGS 1984 geographic coordinate system.

mb_isochrone(
  location,
  profile = "driving",
  time = c(5, 10, 15),
  distance = NULL,
  depart_at = NULL,
  access_token = NULL,
  denoise = 1,
  generalize = NULL,
  geometry = "polygon",
  output = "sf",
  rate_limit = 300,
  keep_color_cols = FALSE,
  id_column = NULL
)

Arguments

location

A vector of form c(longitude, latitude), an address that can be geocoded as a character string, or an sf object.

profile

One of "driving", "walking", "cycling", or "driving-traffic". "driving" is the default.

time

A vector of isochrone contours, specified in minutes. Defaults to c(5, 10, 15). The maximum time supported is 60 minutes. Reflects traffic conditions for the date and time at which the function is called. If reproducibility of isochrones is required, supply an argument to the depart_at parameter.

distance

A vector of distance contours specified in meters. If supplied, will supercede any call to the time parameter as time and distance cannot be used simultaneously. Defaults to NULL.

depart_at

(optional) For the "driving" or "driving-traffic" profiles, the departure date and time to reflect historical traffic patterns. If "driving-traffic" is used, live traffic will be mixed in with historical traffic for dates/times near to the current time. Should be specified as an ISO 8601 date/time, e.g. "2022-03-31T09:00". If NULL (the default), isochrones will reflect traffic conditions at the date and time when the function is called.

access_token

A valid Mapbox access token.

denoise

A floating-point value between 0 and 1 used to remove smaller contours. 1 is the default and returns only the largest contour for an input time.

generalize

A value expressed in meters of the tolerance for the Douglas-Peucker generalization algorithm used to simplify the isochrone shapes. If NULL (the default), the Mapbox API will choose an optimal value for you.

geometry

one of "polygon" (the default), which returns isochrones as polygons, or alternatively "linestring", which returns isochrones as linestrings.

output

one of "sf" (the default), which returns an sf object representing the isochrone(s), or "list", which returns the GeoJSON response from the API as an R list.

rate_limit

The rate limit for the API, expressed in maximum number of calls per minute. For most users this will be 300 though this parameter can be modified based on your Mapbox plan. Used when location is "sf".

keep_color_cols

Whether or not to retain the color columns that the Mapbox API generates by default (applies when the output is an sf object). Defaults to FALSE.

id_column

If the input dataset is an sf object, the column in your dataset you want to use as the isochrone ID. Otherwise, isochrone IDs will be identified by row index or position.

Value

An sf object representing the isochrone(s) around the location(s).

Examples

if (FALSE) {

library(mapboxapi)
library(mapdeck)
isochrones <- mb_isochrone("The Kremlin, Moscow Russia",
  time = c(4, 8, 12),
  profile = "walking"
)

mapdeck(style = mapdeck_style("light")) %>%
  add_polygon(
    data = isochrones,
    fill_colour = "time",
    fill_opacity = 0.5,
    legend = TRUE
  )
}