How to plot multiple isochrones on a booklet map in R

I can plot one isochron in R at a time using the Rmapzen package with this code , each isochron is generated as an sp object, is there any way to create a multiple isochron in the same map as the attached pic enter image description here?

+3


source to share


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


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







All Articles