Skip to contents

Heatmap Layer

Usage

add_heatmap_layer(
  rdeck,
  ...,
  id = uuid::UUIDgenerate(),
  name = "HeatmapLayer",
  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",
  get_position = position,
  get_weight = 1,
  intensity = 1,
  radius_pixels = 50,
  color_range = c("#ffffb2", "#fed976", "#feb24c", "#fd8d3c", "#f03b20", "#bd0026"),
  threshold = 0.05,
  color_domain = NULL,
  aggregation = "SUM",
  weights_texture_size = 2048,
  debounce_timeout = 500,
  blending_mode = "normal",
  visibility_toggle = TRUE
)

update_heatmap_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(),
  get_position = cur_value(),
  get_weight = cur_value(),
  intensity = cur_value(),
  radius_pixels = cur_value(),
  color_range = cur_value(),
  threshold = cur_value(),
  color_domain = cur_value(),
  aggregation = cur_value(),
  weights_texture_size = cur_value(),
  debounce_timeout = 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.

get_position

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

get_weight

<accessor | scale | number> The weight of each object. Accepts a single numeric value, a numeric scale, or a tidy-eval column of numbers.

intensity

<number> Value that is multiplied with the total weight at a pixel to obtain the final weight. A value > 1 biases the output colour towards the higher end of the color_range, and a value < 1 biases the output towards the lower end of the color_range.

radius_pixels

<number> The radius of the circle in pixels.

color_range

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

threshold

<number> Larger threshold values creates smoother boundaries of colour blobs, while making pixels with low weight values more transparent. Ignored when color_domain is specified.

color_domain

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

aggregation

<"SUM" | "MEAN" | "MIN" | "MAX"> Defines the aggregation function.

weights_texture_size

<number> The size of the weight texture. Smaller texture sizes can improve rendering performance, but lead to visible pixelation.

debounce_timeout

<number> Debounce interval (milliseconds) for triggering aggregation.

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.