make_isochrone: Make Time Isochrone

Description Usage Arguments Value Examples

View source: R/make_isochrone.R

Description

Generates a time isochrone for travel times to/from a specified location.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
make_isochrone(
  site,
  time,
  direction = c("out", "in"),
  detail = "medium",
  multiplier = 0.8,
  mode = c("driving", "walking", "cycling", "transit"),
  departing = F,
  method = c("google", "mapbox", "google_guess"),
  tz = Sys.timezone(),
  init_grid_size = 5,
  google_api_key = Sys.getenv("google_api_key"),
  mapbox_api_key = Sys.getenv("mapbox_api_key")
)

Arguments

site

either a data.frame with the columns 'lat' and 'lng' or a character string to be geocoded.

time

the travel time in minutes for the isochrone extents

direction

either 'in' or 'out'.'in' generates an isochrone from multiple origins to the site. 'out' goes from the site to multiple destinations.

detail

parameter used for method=google and takes 'low', 'medium' or 'high' level of detail in the isochrone. High will produce the most granular detail but will use more API credits.

multiplier

used to calculate the extents of the google isochrone. It should be tuned using method='google_guess'. In areas with a low speed of traffic, lower multiplier values will be appropriate (~0.7). When the mode is set to walking, a recommended parameter is ~0.1. The interpretation of this value is that a multiplier of 1 means that the maximum distance able to be travelled in 1 minute is 1km.

mode

a character string for the mode of travel. Possible values are 'driving', 'cycling', 'transit', or 'walking'

departing

departure time can be set if we know the departure time and want to take into account traffic in the network for driving or transit modes. Departing should always be set to FALSE for walking or cycling modes. If required, departure time should be specified in the format 'YYYY-MM-DD HH:MM:SS', in the local time of the origin country

method

eithing 'google' or 'mapbox' method for generating isochrones. Read the vingette for more details. 'google_guess' is also available to tune the multiplier parameter.

tz

if departure time is set, timezone defaults to the user's timezone as per 'Sys.timezone'. Where the timezone of the 'site' differs from the user timezone, specify the 'site' timezone here. tz is a character string that must be a time zone that is recognized by the user's OS.

init_grid_size

used for method='google' - adjust if we want to pick up more points in the 'google_guess' stage before adding detail. Useful for longer travel times (>60mins).

google_api_key

the google maps API key. This can be generated from the google cloud console and set using 'set_google_api'

mapbox_api_key

the mapbox maps API key. This can be generated by signing up to a mapbox account and set using 'set_mapbox_api'

Value

an sf polygon

Examples

1
2
3
4
5
6
7
8
9
transit_isochrone <- make_isochrone(site = 'London Bridge Station, London, UK', time = 30,
  direction ='out',  multiplier = 0.7, mode = 'transit')
driving_isochrone_mapbox <- make_isochrone(site = 'London Bridge Station, London, UK',
 time = 30, method = 'mapbox', mode = 'driving')

library(leaflet)
leaflet(driving_isochrone_mapbox) %>%
  addTiles() %>%
  addPolygons()

Chrisjb/RDistanceMatrix documentation built on Jan. 27, 2021, 9:12 p.m.