Title: | An R Interface to 'deck.gl' |
---|---|
Description: | Makes 'deck.gl' <https://deck.gl/>, a WebGL-powered open-source JavaScript framework for visual exploratory data analysis of large datasets, available within R via the 'htmlwidgets' package. Furthermore, it supports basemaps from 'mapbox' <https://www.mapbox.com/> via 'mapbox-gl-js' <https://github.com/mapbox/mapbox-gl-js>. |
Authors: | Stefan Kuethe [aut, cre] |
Maintainer: | Stefan Kuethe <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0 |
Built: | 2025-02-23 04:47:24 UTC |
Source: | https://github.com/crazycapivara/deckgl |
The ArcLayer
renders raised arcs joining pairs of source and target points,
specified as latitude/longitude coordinates.
add_arc_layer(deckgl, data = NULL, properties = list(), ..., id = "arc-layer")
add_arc_layer(deckgl, data = NULL, properties = list(), ..., id = "arc-layer")
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/arc-layer
data("bart_segments") properties <- list( getWidth = 12, getSourcePosition = ~from_lng + from_lat, getTargetPosition = ~to_lng + to_lat, getSourceColor = "@=[Math.sqrt(inbound), 140, 0]", getTargetColor = "@=[Math.sqrt(outbound), 140, 0]", tooltip = use_tooltip( html = "{{from_name}} to {{to_name}}", style = "background: steelBlue; border-radius: 5px;" ) ) deck <- deckgl(zoom = 10, pitch = 35) %>% add_arc_layer(data = bart_segments, properties = properties) %>% add_control("Arc Layer", "top-left") %>% add_basemap() if (interactive()) deck
data("bart_segments") properties <- list( getWidth = 12, getSourcePosition = ~from_lng + from_lat, getTargetPosition = ~to_lng + to_lat, getSourceColor = "@=[Math.sqrt(inbound), 140, 0]", getTargetColor = "@=[Math.sqrt(outbound), 140, 0]", tooltip = use_tooltip( html = "{{from_name}} to {{to_name}}", style = "background: steelBlue; border-radius: 5px;" ) ) deck <- deckgl(zoom = 10, pitch = 35) %>% add_arc_layer(data = bart_segments, properties = properties) %>% add_control("Arc Layer", "top-left") %>% add_basemap() if (interactive()) deck
Add a basemap to the deckgl widget
add_basemap(deckgl, style = use_carto_style(), ...)
add_basemap(deckgl, style = use_carto_style(), ...)
deckgl |
deckgl widget |
style |
The style definition of the map conforming to the Mapbox Style Specification. |
... |
not used |
Add a bitmap layer to the deckgl widget
add_bitmap_layer( deckgl, image = NULL, properties = list(), ..., id = "h3-hexagon-layer" )
add_bitmap_layer( deckgl, image = NULL, properties = list(), ..., id = "h3-hexagon-layer" )
deckgl |
A deckgl widget object. |
image |
image |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
image <- paste0( "https://raw.githubusercontent.com/", "uber-common/deck.gl-data/master/", "website/sf-districts.png" ) bounds <- c(-122.5190, 37.7045, -122.355, 37.829) deck <- deckgl() %>% add_bitmap_layer(image = image, bounds = bounds) %>% add_basemap() if (interactive()) deck
image <- paste0( "https://raw.githubusercontent.com/", "uber-common/deck.gl-data/master/", "website/sf-districts.png" ) bounds <- c(-122.5190, 37.7045, -122.355, 37.829) deck <- deckgl() %>% add_bitmap_layer(image = image, bounds = bounds) %>% add_basemap() if (interactive()) deck
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.
add_column_layer( deckgl, data = NULL, properties = list(), ..., id = "column-layer" )
add_column_layer( deckgl, data = NULL, properties = list(), ..., id = "column-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/column-layer
hexagon_centroids <- system.file("sample-data/centroids.csv", package = "deckgl") %>% read.csv() deck <- deckgl(zoom = 11, pitch = 35) %>% add_column_layer( data = hexagon_centroids, diskResolution = 12, getPosition = ~lng + lat, getElevation = ~value, getFillColor = "@=[48, 128, value * 255, 255]", elevationScale = 5000, radius = 250, extruded = TRUE, tooltip = "Value: {{value}}" ) %>% add_control("Column Layer", "bottom-left") %>% add_basemap() if (interactive()) deck
hexagon_centroids <- system.file("sample-data/centroids.csv", package = "deckgl") %>% read.csv() deck <- deckgl(zoom = 11, pitch = 35) %>% add_column_layer( data = hexagon_centroids, diskResolution = 12, getPosition = ~lng + lat, getElevation = ~value, getFillColor = "@=[48, 128, value * 255, 255]", elevationScale = 5000, radius = 250, extruded = TRUE, tooltip = "Value: {{value}}" ) %>% add_control("Column Layer", "bottom-left") %>% add_basemap() if (interactive()) deck
The ContourLayer
renders contour lines for a given threshold and cell size.
Internally it implements Marching Squares algorithm to generate contour line segments
and feeds them into LineLayer
to render lines.
add_contour_layer( deckgl, data = NULL, properties = list(), ..., id = "contour-layer" )
add_contour_layer( deckgl, data = NULL, properties = list(), ..., id = "contour-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/contour-layer
## @knitr contour-layer data("sf_bike_parking") contours <- list( use_contour_definition( threshold = 1, color = c(255, 0, 0), stroke_width = 2 ), use_contour_definition( threshold = 5, color = c(0, 255, 0), stroke_width = 3 ), use_contour_definition( threshold = 15, color = c(0, 0, 255), stroke_width = 5 ) ) properties <- list( contours = contours, cellSize = 200, elevationScale = 4, getPosition = ~lng + lat ) deck <- deckgl(zoom = 10.5, pitch = 30) %>% add_contour_layer(data = sf_bike_parking, properties = properties) %>% add_control("Contour Layer") %>% add_basemap() if (interactive()) deck
## @knitr contour-layer data("sf_bike_parking") contours <- list( use_contour_definition( threshold = 1, color = c(255, 0, 0), stroke_width = 2 ), use_contour_definition( threshold = 5, color = c(0, 255, 0), stroke_width = 3 ), use_contour_definition( threshold = 15, color = c(0, 0, 255), stroke_width = 5 ) ) properties <- list( contours = contours, cellSize = 200, elevationScale = 4, getPosition = ~lng + lat ) deck <- deckgl(zoom = 10.5, pitch = 30) %>% add_contour_layer(data = sf_bike_parking, properties = properties) %>% add_control("Contour Layer") %>% add_basemap() if (interactive()) deck
Add a control to the widget
add_control(deckgl, html, pos = "top-right", style = NULL)
add_control(deckgl, html, pos = "top-right", style = NULL)
deckgl |
A deckgl widget object. |
html |
The |
pos |
The position of the control. Possible values are |
style |
A |
deck <- deckgl() %>% add_basemap() %>% add_control( "<h1>Blank Base Map</h1>", pos = "top-right", style = "background: #004080; color: white;" ) if (interactive()) deck
deck <- deckgl() %>% add_basemap() %>% add_control( "<h1>Blank Base Map</h1>", pos = "top-right", style = "background: #004080; color: white;" ) if (interactive()) deck
EXPERIMENTAL
add_data(deckgl, data, var_name = "thanksForAllTheFish")
add_data(deckgl, data, var_name = "thanksForAllTheFish")
deckgl |
deckgl widget |
data |
data object |
var_name |
JavaScript variable name used to make the data available |
The GeoJsonLayer
takes in GeoJson formatted data
and renders it as interactive polygons, lines and points.
add_geojson_layer( deckgl, data = NULL, properties = list(), ..., id = "geojson-layer" )
add_geojson_layer( deckgl, data = NULL, properties = list(), ..., id = "geojson-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/geojson-layer
geojson <- paste0( "https://raw.githubusercontent.com/", "uber-common/deck.gl-data/", "master/website/bart.geo.json" ) deck <- deckgl(zoom = 10, pickingRadius = 5) %>% add_geojson_layer( data = geojson, filled = TRUE, extruded = TRUE, getRadius = 100, lineWidthScale = 20, lineWidthMinPixels = 2, getLineWidth = 1, getLineColor = "@=properties.color || 'green'", getFillColor = c(160, 160, 180, 200), getElevation = 30, tooltip = JS("object => object.properties.name || object.properties.station") ) %>% add_basemap() if (interactive()) deck
geojson <- paste0( "https://raw.githubusercontent.com/", "uber-common/deck.gl-data/", "master/website/bart.geo.json" ) deck <- deckgl(zoom = 10, pickingRadius = 5) %>% add_geojson_layer( data = geojson, filled = TRUE, extruded = TRUE, getRadius = 100, lineWidthScale = 20, lineWidthMinPixels = 2, getLineWidth = 1, getLineColor = "@=properties.color || 'green'", getFillColor = c(160, 160, 180, 200), getElevation = 30, tooltip = JS("object => object.properties.name || object.properties.station") ) %>% add_basemap() if (interactive()) deck
The GreatCircleLayer
is a variation of the ArcLayer
.
It renders flat arcs along the great circle joining pairs of source
and target points, specified as latitude/longitude coordinates.
add_great_circle_layer( deckgl, data = NULL, properties = list(), ..., id = "great-circle-layer" )
add_great_circle_layer( deckgl, data = NULL, properties = list(), ..., id = "great-circle-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/great-circle-layer
## @knitr great-circle-layer data("bart_segments") properties <- list( pickable = TRUE, getWidth = 12, getSourcePosition = ~from_lng + from_lat, getTargetPosition = ~to_lng + to_lat, getSourceColor = JS("d => [Math.sqrt(d.inbound), 140, 0]"), getTargetColor = JS("d => [Math.sqrt(d.outbound), 140, 0]"), getTooltip = "{{from_name}} to {{to_name}}" ) deck <- deckgl(zoom = 10, pitch = 35) %>% add_great_circle_layer(data = bart_segments, properties = properties) %>% add_control("Great Circle Layer") %>% add_basemap() if (interactive()) deck
## @knitr great-circle-layer data("bart_segments") properties <- list( pickable = TRUE, getWidth = 12, getSourcePosition = ~from_lng + from_lat, getTargetPosition = ~to_lng + to_lat, getSourceColor = JS("d => [Math.sqrt(d.inbound), 140, 0]"), getTargetColor = JS("d => [Math.sqrt(d.outbound), 140, 0]"), getTooltip = "{{from_name}} to {{to_name}}" ) deck <- deckgl(zoom = 10, pitch = 35) %>% add_great_circle_layer(data = bart_segments, properties = properties) %>% add_control("Great Circle Layer") %>% add_basemap() if (interactive()) deck
The GridCellLayer
can render a grid-based heatmap.
It is a variation of the ColumnLayer
. It takes the constant width / height of all cells and top-left coordinate of each cell.
The grid cells can be given a height using the getElevation
accessor.
add_grid_cell_layer( deckgl, data = NULL, properties = list(), ..., id = "grid-cell-layer" )
add_grid_cell_layer( deckgl, data = NULL, properties = list(), ..., id = "grid-cell-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/grid-cell-layer
hexagon_centroids <- system.file("sample-data/centroids.csv", package = "deckgl") %>% read.csv() deck <- deckgl(zoom = 11, pitch = 35) %>% add_grid_cell_layer( data = hexagon_centroids, getPosition = ~lng + lat, getElevation = ~value, getFillColor = "@=[48, 128, value * 255, 255]", elevationScale = 5000, cellSize = 250, extruded = TRUE, tooltip = "{{value}}" ) %>% add_mapbox_basemap() if (interactive()) deck
hexagon_centroids <- system.file("sample-data/centroids.csv", package = "deckgl") %>% read.csv() deck <- deckgl(zoom = 11, pitch = 35) %>% add_grid_cell_layer( data = hexagon_centroids, getPosition = ~lng + lat, getElevation = ~value, getFillColor = "@=[48, 128, value * 255, 255]", elevationScale = 5000, cellSize = 250, extruded = TRUE, tooltip = "{{value}}" ) %>% add_mapbox_basemap() if (interactive()) deck
The GridLayer
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_layer( deckgl, data = NULL, properties = list(), ..., id = "grid-layer" )
add_grid_layer( deckgl, data = NULL, properties = list(), ..., id = "grid-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/grid-layer
data("sf_bike_parking") properties <- list( filter = "spaces > 4", visible = TRUE, extruded = TRUE, cellSize = 200, elevationScale = 4, getPosition = "@=[lng, lat]", #~lng + lat, colorRange = RColorBrewer::brewer.pal(6, "YlOrRd"), tooltip = "{{position.0}}, {{position.1}}<br/>Count: {{count}}" ) deck <- deckgl(zoom = 11, pitch = 45, bearing = 35, element_id = "grid-layer") %>% add_source("sf-bike-parking", sf_bike_parking) %>% add_grid_layer( source = "sf-bike-parking", properties = properties ) %>% add_control("Grid Layer") %>% add_basemap() %>% add_json_editor(wrap = 50, maxLines = 23) if (interactive()) deck
data("sf_bike_parking") properties <- list( filter = "spaces > 4", visible = TRUE, extruded = TRUE, cellSize = 200, elevationScale = 4, getPosition = "@=[lng, lat]", #~lng + lat, colorRange = RColorBrewer::brewer.pal(6, "YlOrRd"), tooltip = "{{position.0}}, {{position.1}}<br/>Count: {{count}}" ) deck <- deckgl(zoom = 11, pitch = 45, bearing = 35, element_id = "grid-layer") %>% add_source("sf-bike-parking", sf_bike_parking) %>% add_grid_layer( source = "sf-bike-parking", properties = properties ) %>% add_control("Grid Layer") %>% add_basemap() %>% add_json_editor(wrap = 50, maxLines = 23) if (interactive()) deck
Add a h3 cluster layer to the deckgl widget
add_h3_cluster_layer( deckgl, data = NULL, properties = list(), ..., id = "h3-cluster-layer" )
add_h3_cluster_layer( deckgl, data = NULL, properties = list(), ..., id = "h3-cluster-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/h3-cluster-layer
## @knitr h3-cluster-layer data_url <- paste0( "https://raw.githubusercontent.com/uber-common/deck.gl-data/", "master/website/sf.h3clusters.json" ) # sample_data <- jsonlite::fromJSON(data_url, simplifyDataFrame = FALSE) sample_data <- data_url properties <- list( stroked = TRUE, filled = TRUE, extruded = FALSE, getHexagons = ~hexIds, getFillColor = JS("d => [255, (1 - d.mean / 500) * 255, 0]"), getLineColor = c(255, 255, 255), lineWidthMinPixels = 2, getTooltip = ~mean ) deck <- deckgl(zoom = 10.5, pitch = 20) %>% add_h3_cluster_layer(data = sample_data, properties = properties) %>% add_basemap() if (interactive()) deck
## @knitr h3-cluster-layer data_url <- paste0( "https://raw.githubusercontent.com/uber-common/deck.gl-data/", "master/website/sf.h3clusters.json" ) # sample_data <- jsonlite::fromJSON(data_url, simplifyDataFrame = FALSE) sample_data <- data_url properties <- list( stroked = TRUE, filled = TRUE, extruded = FALSE, getHexagons = ~hexIds, getFillColor = JS("d => [255, (1 - d.mean / 500) * 255, 0]"), getLineColor = c(255, 255, 255), lineWidthMinPixels = 2, getTooltip = ~mean ) deck <- deckgl(zoom = 10.5, pitch = 20) %>% add_h3_cluster_layer(data = sample_data, properties = properties) %>% add_basemap() if (interactive()) deck
Add a h3 hexagon layer to the deckgl widget
add_h3_hexagon_layer( deckgl, data = NULL, properties = list(), ..., id = "h3-hexagon-layer" )
add_h3_hexagon_layer( deckgl, data = NULL, properties = list(), ..., id = "h3-hexagon-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/h3-hexagon-layer
## @knitr h3-hexagon-layer-layer h3_cells <- system.file("sample-data/h3-cells.csv", package = "deckgl") %>% read.csv() properties <- list( getHexagon = ~h3_index, getFillColor =JS("d => [255, (1 - d.count / 500) * 255, 0]"), getElevation = ~count, elevationScale = 20, getTooltip = "{{h3_index}}: {{count}}" ) deck <- deckgl(zoom = 11, pitch = 35) %>% add_h3_hexagon_layer(data = h3_cells, properties = properties) %>% add_control("H3 Hexagon Layer") %>% add_basemap() if (interactive()) deck
## @knitr h3-hexagon-layer-layer h3_cells <- system.file("sample-data/h3-cells.csv", package = "deckgl") %>% read.csv() properties <- list( getHexagon = ~h3_index, getFillColor =JS("d => [255, (1 - d.count / 500) * 255, 0]"), getElevation = ~count, elevationScale = 20, getTooltip = "{{h3_index}}: {{count}}" ) deck <- deckgl(zoom = 11, pitch = 35) %>% add_h3_hexagon_layer(data = h3_cells, properties = properties) %>% add_control("H3 Hexagon Layer") %>% add_basemap() if (interactive()) deck
The HeatmapLayer
can be used to visualize spatial distribution of data.
It internally implements Gaussian Kernel Density Estimation to render heatmaps.
add_heatmap_layer( deckgl, id = "heatmap-layer", data = NULL, properties = list(), ... )
add_heatmap_layer( deckgl, id = "heatmap-layer", data = NULL, properties = list(), ... )
deckgl |
A deckgl widget object. |
id |
The unique id of the layer. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
https://deck.gl/#/documentation/deckgl-api-reference/layers/heatmap-layer
## @knitr heatmap-layer data("sf_bike_parking") map <- deckgl() %>% add_heatmap_layer( data = sf_bike_parking, getPosition = ~lng + lat, getWeight = ~spaces ) %>% add_basemap() if (interactive()) map
## @knitr heatmap-layer data("sf_bike_parking") map <- deckgl() %>% add_heatmap_layer( data = sf_bike_parking, getPosition = ~lng + lat, getWeight = ~spaces ) %>% add_basemap() if (interactive()) map
The HexagonLayer
renders a hexagon heatmap based on an array of points. It takes the radius of hexagon bin, projects points into hexagon bins.
The color and height of the hexagon is scaled by number of points it contains.
add_hexagon_layer( deckgl, data = NULL, properties = list(), ..., id = "hexagon-layer" )
add_hexagon_layer( deckgl, data = NULL, properties = list(), ..., id = "hexagon-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/hexagon-layer
## @knitr hexagon-layer data("sf_bike_parking") properties <- list( extruded = TRUE, radius = 200, elevationScale = 4, getPosition = ~lng + lat, colorRange = RColorBrewer::brewer.pal(6, "Oranges"), tooltip = " <p>{{position.0}}, {{position.1}}<p> <p>Count: {{points.length}}</p> <p>{{#points}}<div>{{address}}</div>{{/points}}</p> ", onClick = JS("obj => console.log(obj)"), autoHighlight = TRUE ) deck <- deckgl(zoom = 11, pitch = 45, bearing = 35) %>% add_hexagon_layer(data = sf_bike_parking, properties = properties) %>% add_control("Hexagon Layer", "top-left") %>% add_basemap() if (interactive()) deck
## @knitr hexagon-layer data("sf_bike_parking") properties <- list( extruded = TRUE, radius = 200, elevationScale = 4, getPosition = ~lng + lat, colorRange = RColorBrewer::brewer.pal(6, "Oranges"), tooltip = " <p>{{position.0}}, {{position.1}}<p> <p>Count: {{points.length}}</p> <p>{{#points}}<div>{{address}}</div>{{/points}}</p> ", onClick = JS("obj => console.log(obj)"), autoHighlight = TRUE ) deck <- deckgl(zoom = 11, pitch = 45, bearing = 35) %>% add_hexagon_layer(data = sf_bike_parking, properties = properties) %>% add_control("Hexagon Layer", "top-left") %>% add_basemap() if (interactive()) deck
The IconLayer
renders raster icons at given coordinates.
add_icon_layer( deckgl, data = NULL, properties = use_default_icon_properties(), ..., id = "icon-layer" )
add_icon_layer( deckgl, data = NULL, properties = use_default_icon_properties(), ..., id = "icon-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/icon-layer
## @knitr icon-layer data("bart_stations") properties <- list( iconAtlas = encode_icon_atlas(), iconMapping = list(marker = use_icon_definition()), sizeScale = 10, getPosition = ~lng + lat, getIcon = JS("d => 'marker'"), getSize = 5, getColor = JS("d => [Math.sqrt(d.exits), 140, 0]"), getTooltip = "{{name}}<br/>{{address}}" ) deck <- deckgl(zoom = 10, pitch = 45) %>% add_icon_layer(data = bart_stations, properties = properties) %>% add_control("Icon Layer") %>% add_basemap() if (interactive()) deck
## @knitr icon-layer data("bart_stations") properties <- list( iconAtlas = encode_icon_atlas(), iconMapping = list(marker = use_icon_definition()), sizeScale = 10, getPosition = ~lng + lat, getIcon = JS("d => 'marker'"), getSize = 5, getColor = JS("d => [Math.sqrt(d.exits), 140, 0]"), getTooltip = "{{name}}<br/>{{address}}" ) deck <- deckgl(zoom = 10, pitch = 45) %>% add_icon_layer(data = bart_stations, properties = properties) %>% add_control("Icon Layer") %>% add_basemap() if (interactive()) deck
Adds a Ace
-editor in JSON mode to the map to interact with the layers of your deck
instance.
add_json_editor(deckgl, ..., style = "width: 40%;", theme = "idle_fingers")
add_json_editor(deckgl, ..., style = "width: 40%;", theme = "idle_fingers")
deckgl |
A deckgl widget object. |
... |
Optional args that are passed to the editor. See https://github.com/ajaxorg/ace/wiki/Configuring-Ace for a list of available options. |
style |
A |
theme |
The name of the theme used by the editor. |
Generic function to add any kind of layer to the deckgl widget.
Usually you will not use this one but any of the add_*_layer
functions instead.
add_layer( deckgl, class_name, data = NULL, properties = list(), ..., id = "hopeful-hopper", tooltip = NULL, source = NULL, filter = NULL )
add_layer( deckgl, class_name, data = NULL, properties = list(), ..., id = "hopeful-hopper", tooltip = NULL, source = NULL, filter = NULL )
deckgl |
A deckgl widget object. |
class_name |
The name of the JavaScript layer class, e. g. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
tooltip |
A tooltip template that defines what should be displayed when the mouse enters an object.
You can also pass a list with the properties |
source |
The ID of the data source. See |
filter |
A filter expression that is applied to the data object. |
A deckgl widget object.
Add a legend to the deckgl widget
add_legend( deckgl, colors, labels, title = NULL, pos = "top-right", style = NULL, ... )
add_legend( deckgl, colors, labels, title = NULL, pos = "top-right", style = NULL, ... )
deckgl |
A deckgl widget object. |
colors |
The colors of the legend items. |
labels |
The labels corresponding to the colors of the legend items. |
title |
The title of the legend. |
pos |
The position of the control. Possible values are |
style |
A |
... |
not used |
Add a legend to the deckgl widget using a palette func
add_legend_pal(deckgl, pal, ...)
add_legend_pal(deckgl, pal, ...)
deckgl |
A deckgl widget object. |
pal |
A palette function that is used to create the legend elements (colors and labels) automatically. |
... |
Parameters that are passed to |
col_numeric
et cetera for how to create a palette function.
The LineLayer
renders flat lines joining pairs of source and target points,
specified as latitude/longitude coordinates.
add_line_layer( deckgl, data = NULL, properties = list(), ..., id = "line-layer" )
add_line_layer( deckgl, data = NULL, properties = list(), ..., id = "line-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/line-layer
## @knitr line-layer data("bart_segments") properties <- list( pickable = TRUE, getWidth = 12, getSourcePosition = ~from_lng + from_lat, getTargetPosition = ~to_lng + to_lat, getColor = JS("d => [Math.sqrt(d.inbound + d.outbound), 140, 0]"), tooltip = "{{from_name}}} to {{to_name}}" ) deck <- deckgl(zoom = 10, pitch = 20) %>% add_line_layer(data = bart_segments, properties = properties) %>% add_basemap() %>% add_control("Line Layer") if (interactive()) deck
## @knitr line-layer data("bart_segments") properties <- list( pickable = TRUE, getWidth = 12, getSourcePosition = ~from_lng + from_lat, getTargetPosition = ~to_lng + to_lat, getColor = JS("d => [Math.sqrt(d.inbound + d.outbound), 140, 0]"), tooltip = "{{from_name}}} to {{to_name}}" ) deck <- deckgl(zoom = 10, pitch = 20) %>% add_line_layer(data = bart_segments, properties = properties) %>% add_basemap() %>% add_control("Line Layer") if (interactive()) deck
Add a basemap from mapbox to the deckgl widget
add_mapbox_basemap( deckgl, style = "mapbox://styles/mapbox/light-v9", token = Sys.getenv("MAPBOX_API_TOKEN") )
add_mapbox_basemap( deckgl, style = "mapbox://styles/mapbox/light-v9", token = Sys.getenv("MAPBOX_API_TOKEN") )
deckgl |
deckgl widget |
style |
map style |
token |
mapbox API access token |
deckgl widget
The PathLayer
takes in lists of coordinate points and renders them as extruded lines with mitering.
add_path_layer( deckgl, data = NULL, properties = list(), ..., id = "path-layer" )
add_path_layer( deckgl, data = NULL, properties = list(), ..., id = "path-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/path-layer
sample_data <- paste0( "https://raw.githubusercontent.com/", "uber-common/deck.gl-data/", "master/website/bart-lines.json" ) properties <- list( pickable = TRUE, widthScale = 20, widthMinPixels = 2, getPath = ~path, getColor = ~color, getWidth = 5, tooltip = ~name ) deck <- deckgl(pitch = 25, zoom = 10.5) %>% add_path_layer(data = sample_data, properties = properties) %>% add_basemap() %>% add_control("Path Layer") if (interactive()) deck
sample_data <- paste0( "https://raw.githubusercontent.com/", "uber-common/deck.gl-data/", "master/website/bart-lines.json" ) properties <- list( pickable = TRUE, widthScale = 20, widthMinPixels = 2, getPath = ~path, getColor = ~color, getWidth = 5, tooltip = ~name ) deck <- deckgl(pitch = 25, zoom = 10.5) %>% add_path_layer(data = sample_data, properties = properties) %>% add_basemap() %>% add_control("Path Layer") if (interactive()) deck
The PointCloudLayer
takes in points with 3d positions, normals and colors and renders them as spheres with a certain radius.
add_point_cloud_layer( deckgl, data = NULL, properties = list(), ..., id = "point-cloud-layer" )
add_point_cloud_layer( deckgl, data = NULL, properties = list(), ..., id = "point-cloud-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/point-cloud-layer
## @knitr point-cloud-layer sample_data <- paste0( "https://raw.githubusercontent.com/", "uber-common/deck.gl-data/", "master/website/pointcloud.json" ) properties <- list( pickable = TRUE, coordinateSystem = JS("deck.COORDINATE_SYSTEM.METER_OFFSETS"), coordinateOrigin = c(-122.4, 37.74), pointSize = 4, getPosition = ~position, getNormal = ~normal, getColor = ~color, lightSettings = list(), tooltip = "{{position.0}}, {{position.1}}" ) deck <- deckgl(pitch = 45, zoom = 10.5) %>% add_point_cloud_layer(data = sample_data, properties = properties) %>% add_basemap() %>% add_control("Point Cloud Layer") if (interactive()) deck
## @knitr point-cloud-layer sample_data <- paste0( "https://raw.githubusercontent.com/", "uber-common/deck.gl-data/", "master/website/pointcloud.json" ) properties <- list( pickable = TRUE, coordinateSystem = JS("deck.COORDINATE_SYSTEM.METER_OFFSETS"), coordinateOrigin = c(-122.4, 37.74), pointSize = 4, getPosition = ~position, getNormal = ~normal, getColor = ~color, lightSettings = list(), tooltip = "{{position.0}}, {{position.1}}" ) deck <- deckgl(pitch = 45, zoom = 10.5) %>% add_point_cloud_layer(data = sample_data, properties = properties) %>% add_basemap() %>% add_control("Point Cloud Layer") if (interactive()) deck
The PolygonLayer
renders filled and/or stroked polygons.
add_polygon_layer( deckgl, data = NULL, properties = list(), ..., id = "polygon-layer" )
add_polygon_layer( deckgl, data = NULL, properties = list(), ..., id = "polygon-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/polygon-layer
## @knitr polygon-layer sample_data <- paste0( "https://raw.githubusercontent.com/", "uber-common/deck.gl-data/", "master/website/sf-zipcodes.json" ) properties <- list( pickable = TRUE, stroked = TRUE, filled = TRUE, wireframe = TRUE, lineWidthMinPixels = 1, getPolygon = ~contour, getElevation = JS("d => d.population / d.area / 10"), getFillColor = JS("d => [d.population / d.area / 60, 140, 0]"), getLineColor = c(80, 80, 80), getLineWidth = 1, tooltip = "{{zipcode}}<br/>Population: {{population}}" ) deck <- deckgl(zoom = 11, pitch = 25) %>% add_polygon_layer(data = sample_data, properties = properties) %>% add_basemap() %>% add_control("Polygon Layer") if (interactive()) deck
## @knitr polygon-layer sample_data <- paste0( "https://raw.githubusercontent.com/", "uber-common/deck.gl-data/", "master/website/sf-zipcodes.json" ) properties <- list( pickable = TRUE, stroked = TRUE, filled = TRUE, wireframe = TRUE, lineWidthMinPixels = 1, getPolygon = ~contour, getElevation = JS("d => d.population / d.area / 10"), getFillColor = JS("d => [d.population / d.area / 60, 140, 0]"), getLineColor = c(80, 80, 80), getLineWidth = 1, tooltip = "{{zipcode}}<br/>Population: {{population}}" ) deck <- deckgl(zoom = 11, pitch = 25) %>% add_polygon_layer(data = sample_data, properties = properties) %>% add_basemap() %>% add_control("Polygon Layer") if (interactive()) deck
EXPERIMENTAL, see https://deck.gl/#/examples/core-layers/tile-layer
add_raster_tile_layer( deckgl, id = "raster-tiles", tileServer = "https://c.tile.openstreetmap.org/", properties = list(), ... )
add_raster_tile_layer( deckgl, id = "raster-tiles", tileServer = "https://c.tile.openstreetmap.org/", properties = list(), ... )
deckgl |
A deckgl widget object. |
id |
The unique id of the layer. |
tileServer |
base url of the tile server |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
## @knitr raster-tile-layer tile_servers <- list( osm = "https://a.tile.openstreetmap.org/", carto_light = "https://cartodb-basemaps-a.global.ssl.fastly.net/light_all/", carto_dark = "https://cartodb-basemaps-a.global.ssl.fastly.net/dark_all/", stamen_toner = "http://a.tile.stamen.com/toner/" ) deck <- deckgl() %>% add_raster_tile_layer( tileServer = tile_servers$osm, pickable = TRUE, autoHighlight = TRUE, highlightColor = c(60, 60, 60, 40) ) if (interactive()) deck
## @knitr raster-tile-layer tile_servers <- list( osm = "https://a.tile.openstreetmap.org/", carto_light = "https://cartodb-basemaps-a.global.ssl.fastly.net/light_all/", carto_dark = "https://cartodb-basemaps-a.global.ssl.fastly.net/dark_all/", stamen_toner = "http://a.tile.stamen.com/toner/" ) deck <- deckgl() %>% add_raster_tile_layer( tileServer = tile_servers$osm, pickable = TRUE, autoHighlight = TRUE, highlightColor = c(60, 60, 60, 40) ) if (interactive()) deck
The ScatterplotLayer
takes in paired latitude and longitude coordinated points
and renders them as circles with a certain radius.
add_scatterplot_layer( deckgl, data = NULL, properties = list(), ..., id = "scatterplot-layer" )
add_scatterplot_layer( deckgl, data = NULL, properties = list(), ..., id = "scatterplot-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/scatterplot-layer
data("bart_stations") properties <- list( getPosition = ~lng + lat, getRadius = "@=Math.sqrt(exits)", #JS("data => Math.sqrt(data.exits)"), radiusScale = 6, getFillColor = "@=code === 'LF' ? 'white': 'red'", #c(255, 140, 20), tooltip = "{{name}}" ) deck <- deckgl(zoom = 10.5, pitch = 35) %>% add_scatterplot_layer(data = bart_stations, properties = properties) %>% add_basemap() %>% add_control("Scatterplot Layer") if (interactive()) deck
data("bart_stations") properties <- list( getPosition = ~lng + lat, getRadius = "@=Math.sqrt(exits)", #JS("data => Math.sqrt(data.exits)"), radiusScale = 6, getFillColor = "@=code === 'LF' ? 'white': 'red'", #c(255, 140, 20), tooltip = "{{name}}" ) deck <- deckgl(zoom = 10.5, pitch = 35) %>% add_scatterplot_layer(data = bart_stations, properties = properties) %>% add_basemap() %>% add_control("Scatterplot Layer") if (interactive()) deck
The ScreenGridLayer
takes in an array of latitude and longitude coordinated points,
aggregates them into histogram bins and renders as a grid.
add_screen_grid_layer( deckgl, data = NULL, properties = list(), ..., id = "screen-grid-layer" )
add_screen_grid_layer( deckgl, data = NULL, properties = list(), ..., id = "screen-grid-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/screen-grid-layer
## @knitr screen-grid-layer data("sf_bike_parking") properties <- list( opacity = 0.8, cellSizePixels = 50, colorRange = RColorBrewer::brewer.pal(6, "Blues"), getPosition = ~lng + lat, getWeight = ~spaces ) deck <- deckgl() %>% add_screen_grid_layer(data = sf_bike_parking, properties = properties) %>% add_basemap() %>% add_control("Screen Grid Layer") if (interactive()) deck
## @knitr screen-grid-layer data("sf_bike_parking") properties <- list( opacity = 0.8, cellSizePixels = 50, colorRange = RColorBrewer::brewer.pal(6, "Blues"), getPosition = ~lng + lat, getWeight = ~spaces ) deck <- deckgl() %>% add_screen_grid_layer(data = sf_bike_parking, properties = properties) %>% add_basemap() %>% add_control("Screen Grid Layer") if (interactive()) deck
Add a data source to the deckgl widget
add_source(deckgl, id, data)
add_source(deckgl, id, data)
deckgl |
A deckgl widget object. |
id |
The unique id of the source. |
data |
The url to fetch data from or a data object. |
data("bart_stations") deckgl() %>% add_source("bart-stations", bart_stations) %>% add_scatterplot_layer( source = "bart-stations", getPosition = ~lng + lat, getFillColor = "steelblue", getRadius = 50, radiusScale = 6 ) %>% add_text_layer( source = "bart-stations", getPosition = ~lng + lat, getText = ~name, getSize = 15, sizeScale = 1.5, getColor = "white" ) %>% add_basemap()
data("bart_stations") deckgl() %>% add_source("bart-stations", bart_stations) %>% add_scatterplot_layer( source = "bart-stations", getPosition = ~lng + lat, getFillColor = "steelblue", getRadius = 50, radiusScale = 6 ) %>% add_text_layer( source = "bart-stations", getPosition = ~lng + lat, getText = ~name, getSize = 15, sizeScale = 1.5, getColor = "white" ) %>% add_basemap()
Add source as JavaScript dep
add_source_as_dep(deckgl, id, data)
add_source_as_dep(deckgl, id, data)
deckgl |
A deckgl widget object. |
id |
The unique id of the source. |
data |
The url to fetch data from or a data object. |
The TextLayer
renders text labels on the map using texture mapping.
add_text_layer( deckgl, data = NULL, properties = list(), ..., id = "text-layer" )
add_text_layer( deckgl, data = NULL, properties = list(), ..., id = "text-layer" )
deckgl |
A deckgl widget object. |
data |
The url to fetch data from or a data object. |
properties |
A named list of properties with names corresponding to the properties defined
in the deckgl-api-reference
for the given layer class. The |
... |
Named arguments that will be added to the |
id |
The unique id of the layer. |
https://deck.gl/#/documentation/deckgl-api-reference/layers/text-layer
## @knitr text-layer data("bart_stations") deck <- deckgl(zoom = 10, pitch = 35) %>% add_text_layer( data = bart_stations, pickable = TRUE, getPosition = ~lng + lat, getText = ~name, getSize = 15, getAngle = 0, getTextAnchor = "middle", getAlignmentBaseline = "center", tooltip = "{{name}}<br/>{{address}}" ) %>% add_basemap(use_carto_style("voyager")) if (interactive()) deck
## @knitr text-layer data("bart_stations") deck <- deckgl(zoom = 10, pitch = 35) %>% add_text_layer( data = bart_stations, pickable = TRUE, getPosition = ~lng + lat, getText = ~name, getSize = 15, getAngle = 0, getTextAnchor = "middle", getAlignmentBaseline = "center", tooltip = "{{name}}<br/>{{address}}" ) %>% add_basemap(use_carto_style("voyager")) if (interactive()) deck
bart segments
bart_segments
bart_segments
tibble with 45 rows and 8 variables:
number of inbound trips
number of outbound trips
name of source station
longitude of source station
latitude of source station
name of target station
longitude of target station
latitude of target station
https://raw.githubusercontent.com/uber-common/deck.gl-data/master/website/bart-segments.json
bart stations
bart_stations
bart_stations
tibble with 44 rows and 7 variables:
station name
two-letter station code
address
number of entries
number of exits
longitude
latitude
https://raw.githubusercontent.com/uber-common/deck.gl-data/master/website/bart-stations.json
Create a deckgl widget
deckgl( latitude = 37.8, longitude = -122.45, zoom = 12, pitch = 0, bearing = 0, initial_view_state = NULL, views = NULL, width = NULL, height = NULL, element_id = NULL, ... )
deckgl( latitude = 37.8, longitude = -122.45, zoom = 12, pitch = 0, bearing = 0, initial_view_state = NULL, views = NULL, width = NULL, height = NULL, element_id = NULL, ... )
latitude |
The latitude of the initial view state. |
longitude |
The longitude of the initial view state. |
zoom |
The zoom level of the initial view state. |
pitch |
The pitch of the initial view state. |
bearing |
The bearing of the initial view state. |
initial_view_state |
The initial view state.
If set, other view state arguments ( |
views |
A single |
width |
The width of the widget. |
height |
The height of the widget. |
element_id |
The explicit id of the widget (usually not needed). |
... |
Optional properties that are passed to the |
deckgl widget
https://deck.gl/#/documentation/deckgl-api-reference/deck for optional properties
that can be passed to the deck
instance.
Creates a deckgl-like object that can be used to update a deckgl object that has already been rendered.
deckgl_proxy(shinyId, session = shiny::getDefaultReactiveDomain())
deckgl_proxy(shinyId, session = shiny::getDefaultReactiveDomain())
shinyId |
single-element character vector indicating the output ID of the deck to modify |
session |
the |
Output and render functions for using deckgl within Shiny applications and interactive Rmd documents.
deckglOutput(outputId, width = "100%", height = "400px") renderDeckgl(expr, env = parent.frame(), quoted = FALSE)
deckglOutput(outputId, width = "100%", height = "400px") renderDeckgl(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width , height
|
Must be a valid CSS unit (like |
expr |
An expression that generates a deckgl |
env |
The environment in which to evaluate |
quoted |
Is |
Check if everything works fine
does_it_work(token = NULL)
does_it_work(token = NULL)
token |
mapbox API access token |
Encode atlas image to base64
encode_icon_atlas(filename = NULL)
encode_icon_atlas(filename = NULL)
filename |
The filename of the atlas image. |
base64 encoded atlas image
Creates a JS method to retrieve the color of each object. The method parses the HEX color property of the data object to an rgb color array.
get_color_to_rgb_array(color_property)
get_color_to_rgb_array(color_property)
color_property |
property name of data object containing the HEX color |
JavaScript code evaluated on the client-side
Create a data accessor retrieving the first element of an array
get_first_element(property_name)
get_first_element(property_name)
property_name |
property name of data object |
JavaScript code evaluated on the client-side
Create a data accessor retrieving the last element of an array
get_last_element(property_name)
get_last_element(property_name)
property_name |
property name of data object |
JavaScript code evaluated on the client-side
Creates a JS method to retrieve the position of each object.
get_position(latitude = NULL, longitude = NULL, coordinates = NULL)
get_position(latitude = NULL, longitude = NULL, coordinates = NULL)
latitude |
latitude property of data object |
longitude |
longitude property of data object |
coordinates |
coordinates property of data object
(in this case |
JavaScript code evaluated on the client-side
Creates a JS method to retrieve a given property of each object.
get_property(property_name)
get_property(property_name)
property_name |
property name of data object |
JavaScript code evaluated on the client-side
Set the view state of the map
set_view_state( deckgl, latitude = 37.8, longitude = -122.45, zoom = 12, pitch = 0, bearing = 0 )
set_view_state( deckgl, latitude = 37.8, longitude = -122.45, zoom = 12, pitch = 0, bearing = 0 )
deckgl |
A deckgl widget object. |
latitude |
The latitude of the view state. |
longitude |
The longitude of the view state. |
zoom |
The zoom level of the view state. |
pitch |
The pitch of the view state. |
bearing |
The bearing of the view state. |
sf bike parking
sf_bike_parking
sf_bike_parking
tibble with 2520 rows and 5 variables:
address
number of racks
number of spaces
longitude
latidude
https://raw.githubusercontent.com/uber-common/deck.gl-data/master/website/sf-bike-parking.json
Shiny
appSend commands to a deckgl instance in a Shiny
app
update_deckgl(proxy, ...)
update_deckgl(proxy, ...)
proxy |
deckgl proxy object |
... |
unused |
Use a Carto style
use_carto_style(theme = "dark-matter")
use_carto_style(theme = "dark-matter")
theme |
The theme of the style, |
Create a contour definition
use_contour_definition( threshold = 1, color = c(255, 255, 255), stroke_width = 1 )
use_contour_definition( threshold = 1, color = c(255, 255, 255), stroke_width = 1 )
threshold |
The threshold value used in contour generation. |
color |
The RGB color array used to render contour lines. |
stroke_width |
The width of the contour lines in pixels. |
Returns icon properties with default values for iconAtlas
, iconMapping
and getIcon
, so that the default icon is used.
use_default_icon_properties( sizeScale = 15, getSize = 5, getColor = c(240, 140, 0) )
use_default_icon_properties( sizeScale = 15, getSize = 5, getColor = c(240, 140, 0) )
sizeScale |
icon size multiplier |
getSize |
height of each object (in pixels), if a number is provided, it is used as the size for all objects, if a function is provided, it is called on each object to retrieve its size |
getColor |
rgba color of each object, if an array is provided, it is used as the color for all objects if a function is provided, it is called on each object to retrieve its color |
Create an icon definition on an atlas image
use_icon_definition( x = 0, y = 0, width = 128, height = 128, anchor_x = (width/2), anchor_y = 128, mask = TRUE )
use_icon_definition( x = 0, y = 0, width = 128, height = 128, anchor_x = (width/2), anchor_y = 128, mask = TRUE )
x |
The x position of the icon on the atlas image. |
y |
The y position of the icon on the atlas image. |
width |
The width of the icon on the atlas image. |
height |
The height of the icon on the atlas image. |
anchor_x |
The horizontal position of the icon anchor. |
anchor_y |
the vertical position of the icon anchor. |
mask |
whether icon is treated as a transparency mask,
if |
Create a tooltip property
use_tooltip(html, style, ...)
use_tooltip(html, style, ...)
html |
The |
style |
A |
... |
not used |
The tooltip string is a mustache template in which variable names are identified
by the double curly brackets (mustache tags) that surround them. The variable names available to the
template are given by deck.gl’s pickingInfo.object
and vary by layer.
mustache for a complete syntax overwiew.
data("bart_segments") props <- list( tooltip = use_tooltip( html = "{{from_name}} to {{to_name}}", style = "background: steelBlue; border-radius: 5px;" ) ) # The picking object of the hexagon layer offers # a property that contains the list of points of the hexagon. # You can iterate over this list as shown below. data("sf_bike_parking") html = " <p>{{position.0}}, {{position.1}}<p> <p>Count: {{points.length}}</p> <p>{{#points}}<div>{{address}}</div>{{/points}}</p> "
data("bart_segments") props <- list( tooltip = use_tooltip( html = "{{from_name}} to {{to_name}}", style = "background: steelBlue; border-radius: 5px;" ) ) # The picking object of the hexagon layer offers # a property that contains the list of points of the hexagon. # You can iterate over this list as shown below. data("sf_bike_parking") html = " <p>{{position.0}}, {{position.1}}<p> <p>Count: {{points.length}}</p> <p>{{#points}}<div>{{address}}</div>{{/points}}</p> "