How to plot multiple isochrones on a booklet map in R
2 answers
Hi, it is possible to create multiple isochrones on a flyer map using the TravelTime API. You just need to set the departure / arrival time for each figure, the transport mode and the maximum travel time for the isochron. Take a look at sample request and get API keys from here
(Disclaimer: I work for the company responsible for creating this API)
0
source to share
This works for me. A bit messy though .. Don't forget to change the mapzen key
library(rmapzen)
library(leaflet)
library(ggmap)
#packages
Sys.setenv(MAPZEN_KEY = "mapzen-******")
#API key
ucb <- geocode("Via Giovanni Spadolini 7, Milan, Italy")
ucb1 <- geocode("Via Valtellina 15, Milan, Italy")
#origin address
iso5 <- as_sp(mz_isochrone(
ucb,
costing_model = mz_costing$auto(),
contours = mz_contours(5),
polygons = TRUE
))
iso15 <- as_sp(mz_isochrone(
ucb,
costing_model = mz_costing$auto(),
contours = mz_contours(15),
polygons = TRUE
))
iso1_5 <- as_sp(mz_isochrone(
ucb1,
costing_model = mz_costing$auto(),
contours = mz_contours(5),
polygons = TRUE
))
iso1_15 <- as_sp(mz_isochrone(
ucb1,
costing_model = mz_costing$auto(),
contours = mz_contours(15),
polygons = TRUE
))
m = leaflet() %>%
addProviderTiles("CartoDB.DarkMatter") %>%
addPolygons(data = iso15, color = "green", fillColor = "green", fillOpacity = .5)%>%
addPolygons(data = iso5, color = "blue", fillColor = "blue", fillOpacity = .5)%>%
addPolygons(data = iso1_15, color = "green", fillColor = "green", fillOpacity = .5)%>%
addPolygons(data = iso1_5, color = "blue", fillColor = "blue", fillOpacity = .5)
m
0
source to share