我可以使用带有此代码的 Rmapzen 包一次在 R 中绘制一个等时线,每个等时线都作为 sp 对象生成,有没有办法像所附图片一样在同一张地图上创建多个等时线?
问问题
1195 次
2 回答
0
您好,可以使用 TravelTime API 在传单地图上创建多个等时线。您只需为每个形状、运输方式和等时线的最大行程时间设置出发/到达时间。查看示例请求并从此处获取 API 密钥
(免责声明:我为负责创建此 API 的公司工作)
于 2017-07-03T11:29:23.997 回答
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
于 2017-11-20T14:42:14.880 回答