将R Leaftlet热图颜色更改为红色

时间:2018-12-03 20:31:30

标签: r leaflet

请,我想将Leaftlet KML热图的颜色渐变更改为R中的红色

library(leaflet.extras)

kml <- readr::read_file(
  system.file("examples/data/kml/crimes.kml.zip", package = "leaflet.extras")
)

leaflet() %>%
  setView(-77.0369, 38.9072, 12) %>%
  addProviderTiles(providers$CartoDB.Positron) %>%
  addKMLHeatmap(kml, radius = 7) %>%
  addKML(
    kml,
    markerType = "circleMarker",
    stroke = FALSE, fillColor = "black", fillOpacity = 1,
    markerOptions = markerOptions(radius = 1))

非常感谢

1 个答案:

答案 0 :(得分:0)

我不确定这是否是您要追求的目标,但是在处理热图时,有时可以帮助调整radius值。例如,如果将其从7更改为10,则会得到更强烈的颜色和值。尝试运行此命令,然后查看它是否在执行。 (我还将标记上的fillOpacity更改为.5,以更清晰地显示热图)

library('leaflet.extras')

kml <- readr::read_file(
  system.file("examples/data/kml/crimes.kml.zip", package = "leaflet.extras")
)

leaflet() %>%
  setView(-77.0369, 38.9072, 12) %>%
  addProviderTiles(providers$CartoDB.Positron) %>%
  addKMLHeatmap(kml, radius = 10) %>%
  addKML(
    kml,
    markerType = "circleMarker",
    stroke = FALSE, fillColor = "black", fillOpacity = .5,
    markerOptions = markerOptions(radius = 1))