The Grid Layer renders a grid heatmap based on an array of points. It takes the constant size all each cell, projects points into cells. The color and height of the cell is scaled by number of points it contains.

add_grid(
map,
data = get_map_data(map),
lon = NULL,
lat = NULL,
polyline = NULL,
cell_size = 1000,
extruded = TRUE,
elevation = NULL,
elevation_function = c("sum", "mean", "min", "max"),
colour = NULL,
colour_function = c("sum", "mean", "min", "max"),
elevation_scale = 1,
colour_range = NULL,
legend = FALSE,
legend_options = NULL,
auto_highlight = FALSE,
highlight_colour = "#AAFFFFFF",
layer_id = NULL,
update_view = TRUE,
focus_layer = FALSE,
digits = 6,
transitions = NULL,
)

Arguments

map a mapdeck map object data to be used in the layer. All coordinates are expected to be EPSG:4326 (WGS 84) coordinate system column containing longitude values column containing latitude values optional column of data containing the polylines, if using encoded polylines size of each cell in meters. Default 1000 logical indicating if cells are elevated or not. Default TRUE the height the polygon extrudes from the map. Only available if neither stroke_colour or stroke_width are supplied. Default 0 one of 'min', 'mean', 'max', 'sum'. IF supplied it specifies how the elevation values are calcualted. Defaults to sum. column containing numeric values to colour by. one of 'min', 'mean', 'max', 'sum'. If supplied it specifies how the colour values are calculated. Defaults to sum. elevation multiplier. vector of 6 hex colours either a logical indiciating if the legend(s) should be displayed, or a named list indicating which colour attributes should be included in the legend. A list of options for controlling the legend. logical indicating if the shape under the mouse should auto-highlight hex string colour to use for highlighting. Must contain the alpha component. single value specifying an id for the layer. Use this value to distinguish between shape layers of the same type. Layers with the same id are likely to conflict and not plot correctly logical indicating if the map should update the bounds to include this layer logical indicating if the map should update the bounds to only include this layer number of digits for rounding coordinates list specifying the duration of transitions. radius of the brush in metres. Default NULL. If supplied, the arcs will only show if the origin or destination are within the radius of the mouse. If NULL, all arcs are displayed

Details

add_grid supports POINT and MULTIPOINT sf objects

data

If the data is a simple feature object, the geometry column is automatically detected. If the sf object contains more than one geometry column and you want to use a specific one, you'll need to set the active geometry using sf::st_geometry( x ) <- "your_column" , where "your_column" is the name of the column you're activating. See ?sf::st_geometry

Examples

# \donttest{
key <- 'abc'
set_token( key )

'https://raw.githubusercontent.com/uber-common/deck.gl-data/master/',
'examples/3d-heatmap/heatmap-data.csv'
))

df <- df[ !is.na(df$lng ), ] mapdeck( style = mapdeck_style("dark"), pitch = 45 ) %>% add_grid( data = df , lat = "lat" , lon = "lng" , cell_size = 5000 , elevation_scale = 50 , layer_id = "grid_layer" , auto_highlight = TRUE ) ## using sf object library(sfheaders) sf <- sfheaders::sf_point( df, x = "lng", y = "lat") mapdeck( style = mapdeck_style("dark"), pitch = 45 ) %>% add_grid( data = sf , cell_size = 5000 , elevation_scale = 50 , layer_id = "grid_layer" , auto_highlight = TRUE ) ## using colour and elevation functions, and legends df$val <- sample(1:10, size = nrow(df), replace = T)

mapdeck( style = mapdeck_style("dark"), pitch = 45) %>%
data = df
, lat = "lat"
, lon = "lng"
, layer_id = "hex_layer"
, elevation_scale = 100
, legend = T
, colour_function = "max"
, colour = "val"
)

mapdeck( style = mapdeck_style("dark"), pitch = 45) %>%
# }