我有一个geojson文件,它是路线的形状。在csv文件中,我有utm_lat,utm_lng,pasengers的数据。使用R中的传单,我如何才能创建一个只遵循路线的热图?我需要其他类型的数据文件吗?
我得到类似的东西:enter link description here
但我希望它看起来像这样:enter link description here
我在R shiny app中的一部分代码:heatway1被过滤,其中方向被过滤为way1,heatway2被过滤为way2
heatway1 <- data.frame(heatway1$utm_lng, heatway1$utm_lat, heatway1$passengers)
colnames(heatway1) <- c("lng", "lat", "value")
heatway2 <- data.frame(heatway2$utm_lng, heatway2$utm_lat, heatway2$passengers)
colnames(heatway2) <- c("lng", "lat", "value")
map <- leaflet(filtered_data()) %>%
addTiles() %>%
setView(lng = mean(filtered_data()$utm_lng),
lat = mean(filtered_data()$utm_lat),
zoom = 13)
map <- map %>%
addHeatmap(data = heatway1, intensity = ~value, blur = 20, max = 20, radius = 25, group = "way1")
map <- map %>%
addHeatmap(data = heatway2, intensity = ~value, blur = 20, max = 20, radius = 25, group = "way2")
map <- map %>%
addLegend(
position = "bottomleft",
pal = pal,
values = ~passengers,
title = "Passengers",
opacity = 1
)
map <- map %>% addLayersControl(overlayGroups = c("way1", "way2"), options = layersControlOptions(collapsed = FALSE)) %>%
addGeodesicPolylines(data = geojsonroutedata, color = "#03F", opacity = 0.5) %>%
addResetMapButton() %>% addSearchOSM() %>% addScaleBar(position = "bottomleft") # %>% addFullscreenControl()
1条答案
按热度按时间ie3xauqp1#
据
我得到类似的东西:your link 1但我希望它看起来像这样:your link 2
和你对数据的描述,在制作热图之前捕捉对应于路线的点可能是有用的。你可以用maptools将点捕捉到最近的线:https://maptools.r-forge.r-project.org/reference/snapPointsToLines.html
编辑:
你将不得不通过考虑两种“方式”来改进,但我所描绘的逻辑如下
如果你放大中心,几个初始点与区域的边界很好地对齐。我希望这对你有帮助!