Description Usage Arguments Examples
View source: R/custom_hexbins.R
Get hexbins for given points and resolution
1 2 3 4 5 6 7 8 9 10 11 12 |
data |
matrix, data frame (with latidude and longitude columns)
or object of class |
res |
resolution of hexagons to return; number between 0 and 15 |
... |
ignored |
lat |
name of latitude column |
lng |
name of longitude column |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | library(leaflet)
result <- hexbins(road_safety_greater_manchester)
pal <- colorBin("YlOrRd", domain = result$hexagons$count)
map <- leaflet(data = result$hexagons) %>%
addProviderTiles("Stamen.Toner") %>%
addPolygons(
weight = 2,
color = "white",
fillColor = ~ pal(count),
fillOpacity = 0.8,
label = ~ sprintf("%i accidents", count),
popup = result$hexagons$h3_index
)
if (interactive()) map
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.