knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of traveltimeSF is to provide simple wrappers for converting data from the TravelTime SDK for R to sf. Currently only works with isochrones
You can install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("arthurgailes/traveltimeSF")
Adapted from the TravelTime Github:
library(traveltimeR) #store your credentials in an environment variable # Sys.setenv(TRAVELTIME_ID = "YOUR_API_ID") # Sys.setenv(TRAVELTIME_KEY = "YOUR_API_KEY") library(traveltimeSF) departure_search <- make_search(id = "public transport from Trafalgar Square", departure_time = strftime(as.POSIXlt(Sys.time(), "UTC"), "%Y-%m-%dT%H:%M:%SZ"), travel_time = 900, coords = list(lat = 51.507609, lng = -0.128315), transportation = list(type = "public_transport"), properties = list('is_only_walking')) result <- time_map(departure_searches = departure_search) shp <- time_map_to_sf(result) shp
plot(shp$geometry)
The same function can also work with multiple searches:
departure_search1 <- make_search(id = "public transport from Trafalgar Square", departure_time = "2022-01-01T08:00:00Z", travel_time = 900, coords = list(lat = 51.507609, lng = -0.128315), transportation = list(type = "public_transport"), properties = list('is_only_walking')) departure_search2 <- make_search(id = "driving from Trafalgar Square", departure_time = "2022-01-01T08:00:00Z", travel_time = 900, coords = list(lat = 51.507609, lng = -0.128315), transportation = list(type = "driving")) arrival_search <- make_search(id = "public transport to Trafalgar Square", arrival_time = "2022-01-01T08:00:00Z", travel_time = 900, coords = list(lat = 51.507609, lng = -0.128315), transportation = list(type = "public_transport"), range = list(enabled = T, width = 3600)) union <- make_union_intersect(id = "union of driving and public transport", search_ids = list('driving from Trafalgar Square', 'public transport from Trafalgar Square')) intersection <- make_union_intersect(id = "intersection of driving and public transport", search_ids = list('driving from Trafalgar Square', 'public transport from Trafalgar Square')) multi_search <- time_map( departure_searches = c(departure_search1, departure_search2), arrival_searches = arrival_search, unions = union, intersections = intersection ) time_map_to_sf(multi_search)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.