Description Usage Arguments Details data legend id Examples
View source: R/map_layer_column.R
The ColumnLayer can be used to render a heatmap of vertical cylinders. It renders a tesselated regular polygon centered at each given position (a "disk"), and extrude it in 3d.
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 | add_column(
map,
data = get_map_data(map),
polyline = NULL,
lon = NULL,
lat = NULL,
fill_colour = NULL,
fill_opacity = NULL,
stroke_colour = NULL,
stroke_opacity = NULL,
stroke_width = NULL,
radius = 1000,
elevation = NULL,
elevation_scale = 1,
coverage = 1,
angle = 0,
disk_resolution = 20,
tooltip = NULL,
auto_highlight = FALSE,
highlight_colour = "#AAFFFFFF",
layer_id = NULL,
id = NULL,
palette = "viridis",
na_colour = "#808080FF",
legend = FALSE,
legend_options = NULL,
legend_format = NULL,
update_view = TRUE,
focus_layer = FALSE,
digits = 6,
transitions = NULL,
brush_radius = NULL
)
|
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 |
polyline |
column of |
lon |
column containing longitude values |
lat |
column containing latitude values |
fill_colour |
column of |
fill_opacity |
Either a string specifying the column of |
stroke_colour |
variable of |
stroke_opacity |
Either a string specifying the column of |
stroke_width |
width of the stroke in meters. If used, |
radius |
in metres. Default 1000 |
elevation |
the height the polygon extrudes from the map. Only available if neither
|
elevation_scale |
value to scale the elevations of the columns Default 1 |
coverage |
radius multiplier, in range [0,1]. The radius of the disk is calcualted by coverage * radius |
angle |
disk rotation, counter-clockwise, in degrees |
disk_resolution |
The number of sides to render the disk as. The disk is a regular polygon that fits inside the given radius. A higher resolution will yield a smoother look close-up, but also requires more resources to render. |
tooltip |
variable of |
auto_highlight |
logical indicating if the shape under the mouse should auto-highlight |
highlight_colour |
hex string colour to use for highlighting. Must contain the alpha component. |
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 |
id |
an id value in |
palette |
string or matrix. String will be one of |
na_colour |
hex string colour to use for NA values |
legend |
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. |
legend_options |
A list of options for controlling the legend. |
legend_format |
A list containing functions to apply to legend values. See section legend |
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 |
transitions |
list specifying the duration of transitions. |
brush_radius |
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 |
add_column
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
The legend_options
can be used to control the appearance of the legend.
This should be a named list, where the names are one of
css - a string of valid css
for controlling the appearance of the legend
title - a string to use for the title of the legend
digits - number to round the legend values to
If the layer allows different fill and stroke colours, you can use different options for each. See examples in add_arc.
The legend_format
can be used to control the format of the values in the legend.
This should be a named list, where the names are one of
fill_colour
stroke_colour
depending on which type of colouring the layer supports.
The list elements must be functions to apply to the values in the legend.
The id
is returned to your R session from an interactive shiny environment
by observing layer clicks. This is useful for returning the data.frame row relating to the
cliked shape.
From within a shiny server you would typically use observeEvent({input$map_arc_click})
,
where 'map' is the map_id supplied to mapdeckOutput()
, and 'arc' is the layer
you are clicking on
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 36 37 38 39 | ## Not run:
## You need a valid access token from Mapbox
key <- 'abc'
set_token( key )
df <- capitals
df$elev <- sample(50000:500000, size = nrow(df), replace = TRUE)
mapdeck(style = mapdeck_style("dark"), pitch = 45) %>%
add_column(
data = df
, lat = "lat"
, lon = "lon"
, elevation = "elev"
, fill_colour = "lon"
, disk_resolution = 20
, radius = 100000
, tooltip = "capital"
)
library(sfheaders)
sf <- sfheaders::sf_point( df, x = "lon", y = "lat" )
sf$elev <- df$elev
mapdeck( style = mapdeck_style("dark"), pitch = 45 ) %>%
add_column(
data = sf
, layer_id = "col_layer"
, elevation = "elev"
, radius = 100000
, fill_colour = "country"
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.