Skip to contents

Grid Layer

Usage

add_grid_layer(
  rdeck,
  ...,
  id = uuid::UUIDgenerate(),
  name = "GridLayer",
  group_name = NULL,
  data = NULL,
  visible = TRUE,
  pickable = FALSE,
  opacity = 1,
  wrap_longitude = FALSE,
  position_format = "XY",
  color_format = "RGBA",
  auto_highlight = FALSE,
  highlight_color = "#00008080",
  color_domain = NULL,
  color_range = c("#ffffb2", "#fed976", "#feb24c", "#fd8d3c", "#f03b20", "#bd0026"),
  get_color_weight = 1,
  color_aggregation = "SUM",
  elevation_domain = NULL,
  elevation_range = c(0, 1000),
  get_elevation_weight = 1,
  elevation_aggregation = "SUM",
  elevation_scale = 1,
  cell_size = 1000,
  coverage = 1,
  get_position = position,
  extruded = FALSE,
  material = TRUE,
  get_color_value = NULL,
  lower_percentile = 0,
  upper_percentile = 100,
  color_scale_type = "quantize",
  get_elevation_value = NULL,
  elevation_lower_percentile = 0,
  elevation_upper_percentile = 100,
  elevation_scale_type = "linear",
  gpu_aggregation = FALSE,
  blending_mode = "normal",
  visibility_toggle = TRUE
)

update_grid_layer(
  rdeck,
  ...,
  id,
  name = cur_value(),
  group_name = cur_value(),
  data = cur_value(),
  visible = cur_value(),
  pickable = cur_value(),
  opacity = cur_value(),
  wrap_longitude = cur_value(),
  position_format = cur_value(),
  color_format = cur_value(),
  auto_highlight = cur_value(),
  highlight_color = cur_value(),
  color_domain = cur_value(),
  color_range = cur_value(),
  get_color_weight = cur_value(),
  color_aggregation = cur_value(),
  elevation_domain = cur_value(),
  elevation_range = cur_value(),
  get_elevation_weight = cur_value(),
  elevation_aggregation = cur_value(),
  elevation_scale = cur_value(),
  cell_size = cur_value(),
  coverage = cur_value(),
  get_position = cur_value(),
  extruded = cur_value(),
  material = cur_value(),
  get_color_value = cur_value(),
  lower_percentile = cur_value(),
  upper_percentile = cur_value(),
  color_scale_type = cur_value(),
  get_elevation_value = cur_value(),
  elevation_lower_percentile = cur_value(),
  elevation_upper_percentile = cur_value(),
  elevation_scale_type = cur_value(),
  gpu_aggregation = cur_value(),
  blending_mode = cur_value(),
  visibility_toggle = cur_value()
)

Arguments

rdeck

<rdeck | rdeck_proxy> An rdeck map instance.

...

Additional parameters that will be forwarded to deck.gl javascript without validation nor processing. All dots must be named and will be camelCased when serialised. A warning is raised when dots are used, warning class rdeck_dots_nonempty.

id

<string> The layer's identifier must be unique for among all layers of the same type for a map. Defaults to uuid::UUIDgenerate(), but should be explicitly defined for updatable layers in a shiny application.

name

<string> Identifies the layer on tooltips and legends. It does not need to be unique, but should be brief. Defaults to the deck.gl class name for the layer.

group_name

<string> Defines the group that this layer belongs to. Currently only effective on the layer selector, if visibility_toggle = TRUE.

data

<data.frame | sf | string> The layer's data. Data frames and sf objects will contain all columns that are referenced by the layer's accessors. Strings will be interpreted as a URL and data will be retrieved dynamically in the browser.

visible

<boolean> Determines whether the layer is visible or not; also determines whether any legend elements for the layer will be displayed.

pickable

<boolean> Determines if the layer responds to pointer / touch events.

opacity

<number> Determines the layer's opacity.

wrap_longitude

<boolean> Normalises geometry longitudes.

position_format

<"XY" | "XYZ"> Determines whether each coordinate has two (XY) or three (XYZ) elements.

color_format

<"RGB" | "RGBA"> Determines whether the alpha channel of the colours will be ignored by accessors, making all colours opaque.

auto_highlight

<boolean> When TRUE, the current object hovered by the cursor is highlighted by highlight_color.

highlight_color

<accessor | scale | color> When auto_highlight and pickable are enabled, highlight_color determines the colour of the currently highlighted object. If a single colour value is supplied, that colour will be used to highlight all objects in the layer. Per-object highlighting is achieved with a colour scale, or a tidy-eval column of colours.

color_domain

<number> The colour scale domain, default is set to the range of aggregated weights in each bin.

color_range

<color> The colour palette. color_domain is divided into length(color_range) equal segments, each mapped to one color in color_range.

get_color_weight

<accessor | scale | number> The weight of each object used to calculate the colour value for a bin. Accepts a single numeric value, a numeric scale, or a tidy-eval column of numbers.

color_aggregation

<"SUM" | "MEAN" | "MIN" | "MAX"> Operation used to aggregate data values/weights to calculate a bin's colour.

elevation_domain

<number> The elevation scale input domain. Defaults to the range of the aggregated weights in each bin.

elevation_range

<number> The elevation scale output range.

get_elevation_weight

<accessor | scale | `numeric> The weight of each object used to calculate the elevation value for a bin. Accepts a single numeric value, a numeric scale, or a tidy-eval column of numbers.

elevation_aggregation

<"SUM" | "MEAN" | "MIN" | "MAX"> Operation used to aggregate data values/weights to calculate a bin's elevation value.

elevation_scale

<number> The elevation multiplier.

cell_size

<number> The size of each cell in metres.

coverage

<number> Radius multiplier, between 0 - 1. The radius of each disk is calculated by coverage * radius.

get_position

<accessor> The feature positions. A <point/multipoint> wk-geometry column with CRS EPSG:4326. Supports tidy-eval.

extruded

<boolean> If TRUE, extrude objects along the z-axis; if FALSE, all objects will be flat.

material

<boolean>

get_color_value

<JS> After data objects are aggregated into bins, this accessor is called on each bin to get the value that its colour is based on. If supplied, this will override the effect of get_color_weight and color_aggregation props. See deck.gl docs for details.

lower_percentile

<number> Between 0 and 100. Filter bins and re-calculate colour by lower_percentile. Cells with value < lower_percentile will be hidden.

upper_percentile

<number> Between 0 and 100. Filter bins and re-calculate colour by upper_percentile. Cells with value < upper_percentile will be hidden.

color_scale_type

<"quantize" | "linear" | "quantile" | "ordinal"> The scaling function used to determine the colour of a the grid cell.

get_elevation_value

<JS> After data objects are aggregated into bins, this accessor is called on each bin to get the value that its elevation is based on. If supplied, this will override the effect of get_elevation_weight and elevation_aggregation props. See deck.gl docs for details.

elevation_lower_percentile

<number> Between 0 and 100. Filter bins and re-calculate elevation by elevation_lower_percentile. Cells with value < elevation_lower_percentile will be hidden.

elevation_upper_percentile

<number> Between 0 and 100. Filter bins and re-calculate elevation by elevation_upper_percentile. Cells with value < elevation_upper_percentile will be hidden.

elevation_scale_type

<"quantize" | "linear" | "quantile" | "ordinal"> The scaling function used to determine the elevation of a the grid cell.

gpu_aggregation

<boolean> If TRUE, aggregation is performed on GPU if supported. Requires WebGL2.

blending_mode

<"normal" | "additive" | "subtractive"> Sets the blending mode. Blending modes:

  • normal: Normal blending doesn't alter colours of overlapping objects.

  • additive: Additive blending adds colours of overlapping objects. Useful for highlighting dot density on dark maps.

  • subtractive: Subtractive blending darkens overlapping objects. Useful for highlighting dot density on light maps.

visibility_toggle

<boolean> Whether this layer will appear in the layer selector.