[英]how to plot multiple isochrone on leaflet map in R
Hi it's possible to create multiple isochrones on a leaflet map using the TravelTime API. 您好,可以使用TravelTime API在传单地图上创建多个等时线。 You just need to set a departure/arrival time for each shape, transport mode and maximum travel time for the isochrone.
您只需为等时线设置每种形状,运输模式和最长行程时间的出发/到达时间。 Take a look at a sample request and get API keys from here
查看示例请求并从此处获取API密钥
(Disclaimer: I work for the company responsible for creating this API) (免责声明:我为负责创建此API的公司工作)
This works for me. 这适合我。 A bit messy though.. Remember to change the mapzen key
虽然有点凌乱..记得改变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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.