Description Usage Arguments Details data Examples
View source: R/map_layer_screengrid.R
The Screen Grid Layer takes in an array of latitude and longitude coordinated points, aggregates them into histogram bins and renders as a grid
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
map |
a mapdeck map object |
data |
data to be used in the layer. All coordinates are expected to be EPSG:4326 (WGS 84) coordinate system |
lon |
column containing longitude values |
lat |
column containing latitude values |
polyline |
optional column of |
weight |
the weight of each value. Default 1 |
aggregation |
one of 'min', 'mean', 'max', 'sum'. If supplied it specifies how the weights used. |
colour_range |
vector of 6 hex colours |
opacity |
opacity of cells. Value between 0 and 1. Default 0.8 |
cell_size |
size of grid squares in pixels. Default 50 |
layer_id |
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 |
update_view |
logical indicating if the map should update the bounds to include this layer |
focus_layer |
logical indicating if the map should update the bounds to only include this layer |
digits |
number of digits for rounding coordinates |
add_screengrid
supports POINT and MULTIPOINT sf objects
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ## You need a valid access token from Mapbox
key <- 'abc'
set_token( key )
df <- read.csv(paste0(
'https://raw.githubusercontent.com/uber-common/deck.gl-data/master/',
'examples/3d-heatmap/heatmap-data.csv'
))
df <- df[ !is.na(df$lng), ]
df$weight <- sample(1:10, size = nrow(df), replace = TRUE)
mapdeck( style = mapdeck_style('dark'), pitch = 45 ) %>%
add_screengrid(
data = df
, lat = "lat"
, lon = "lng"
, weight = "weight",
, layer_id = "screengrid_layer"
, cell_size = 10
, opacity = 0.3
)
## as an sf object
library(sfheaders)
sf <- sfheaders::sf_point( df, x = "lng", y = "lat")
mapdeck( style = mapdeck_style('dark'), pitch = 45 ) %>%
add_screengrid(
data = sf
, weight = "weight",
, layer_id = "screengrid_layer"
, cell_size = 10
, opacity = 0.3
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.