我可以使用带有此code的Rmapzen包一次在R中绘制一个等时线,每个等时线都是作为sp对象生成的,有没有办法在相同的地图上创建多个等时线,如附加的图片{ {3}}?
答案 0 :(得分:0)
您可以使用TravelTime API在传单地图上创建多个等时线。您只需为等时线设置每种形状,运输模式和最长行程时间的出发/到达时间。请查看示例请求和get API keys from here
(免责声明:我为负责创建此API的公司工作)
答案 1 :(得分:0)
这对我有用。虽然有点凌乱.. 请记住更改mapzen键
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