add_scatterplot_layer: Add a scatterplot layer to the deckgl widget

View source: R/layers_scatterplot-layer.R

add_scatterplot_layerR Documentation

Add a scatterplot layer to the deckgl widget

Description

The ScatterplotLayer takes in paired latitude and longitude coordinated points and renders them as circles with a certain radius.

Usage

add_scatterplot_layer(
  deckgl,
  data = NULL,
  properties = list(),
  ...,
  id = "scatterplot-layer"
)

Arguments

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 properties parameter can also be an empty list. In this case all props must be passed as named arguments.

...

Named arguments that will be added to the properties object. Identical parameters are overwritten.

id

The unique id of the layer.

See Also

https://deck.gl/#/documentation/deckgl-api-reference/layers/scatterplot-layer

Examples

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

deckgl documentation built on March 7, 2023, 5:37 p.m.