add_hexagon_layer {deckgl}R Documentation

Add a hexagon layer to the deckgl widget

Description

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.

Usage

add_hexagon_layer(deckgl, id = "hexagon-layer", data = NULL,
  properties = list(), ...)

Arguments

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.

...

More properties that will be added to the properties object. This can be useful if you want to use a properties object for more than one layer.

See Also

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

Examples

## @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

[Package deckgl version 0.2.7 Index]