Opens an interactive leaflet map with hexagonal cell polygons. Cells can be colored by a data column, with popups showing cell information on click.
Arguments
- hex_data
A HexData object, or a data.frame with a
cell_idcolumn.- grid
A HexGridInfo object. Required if
hex_datais a data.frame.- value
Optional column name (character) to color cells by. If
NULL, cells are colored uniformly.- palette
Color palette name for continuous values. Default
"viridis".- opacity
Fill opacity (0-1). Default 0.7.
Details
Requires the leaflet package (in Suggests). The map is built using
as_sf() to generate polygon geometries, then rendered as a leaflet
choropleth.
See also
hexify_heatmap() for static ggplot2 maps,
as_sf() for sf conversion
Examples
# \donttest{
if (requireNamespace("leaflet", quietly = TRUE)) {
df <- data.frame(
lon = runif(50, -5, 5),
lat = runif(50, 45, 55),
value = rnorm(50)
)
hd <- hexify(df, lon = "lon", lat = "lat", area_km2 = 500)
hex_browse(hd, value = "value")
}
# }