addHexbin {leaflet.extras2} | R Documentation |
Add a Hexbin layer
Description
Create dynamic hexbin-based heatmaps on Leaflet maps. This plugin leverages the data-binding power of d3 to allow you to dynamically update the data and visualize the transitions.
Usage
addHexbin(
map,
lng = NULL,
lat = NULL,
radius = 20,
layerId = NULL,
group = NULL,
opacity = 0.5,
options = hexbinOptions(),
data = getMapData(map)
)
Arguments
map |
a map widget object created from |
lng |
a numeric vector of longitudes, or a one-sided formula of the form
|
lat |
a vector of latitudes or a formula (similar to the |
radius |
Radius of the hexbin layer |
layerId |
the layer id |
group |
the name of the group the newly created layers should belong to
(for |
opacity |
Opacity of the hexbin layer |
options |
List of further options. See |
data |
the data object from which the argument values are derived; by
default, it is the |
Value
the new map
object
Note
Currently doesn't respect layerId
nor group
.
References
https://github.com/bluehalo/leaflet-d3#hexbins-api
See Also
Other Hexbin-D3 Functions:
clearHexbin()
,
hexbinOptions()
,
hideHexbin()
,
showHexbin()
,
updateHexbin()
Examples
library(leaflet)
library(leaflet.extras2)
n <- 1000
df <- data.frame(lat = rnorm(n, 42.0285, .01),
lng = rnorm(n, -93.65, .01))
leaflet() %>%
addTiles() %>%
addHexbin(lng = df$lng, lat = df$lat,
options = hexbinOptions(
colorRange = c("red", "yellow", "blue"),
radiusRange = c(10, 20)
))