Learn R Programming

deckgl (version 0.2.5)

add_contour_layer: Add a contour layer to the deckgl widget

Description

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.

Usage

add_contour_layer(deckgl, id = "contour-layer", data = NULL,
  properties = list(), ...)

Arguments

deckgl

deckgl widget

id

id of the layer

data

url to fetch data from or data object

properties

named list of properties with names corresponding to the properties defined in the deckgl-api-reference for the given layer class, additionally there is a getTooltip property (callback) showing a tooltip when the mouse enters an object, e. g. getTooltip = JS("object => object.name")

...

more properties (will be added to the properties object), useful if you want to use a properties object for more than one layer

See Also

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

Examples

Run this code
# NOT RUN {
## @knitr contour-layer
data("sf_bike_parking")

contours <- list(
  use_contour_definition(
    threshold = 1,
    color = c(255, 0, 0),
    strokeWidth = 2
  ),
  use_contour_definition(
    threshold = 5,
    color = c(0, 255, 0),
    strokeWidth = 3
  ),
  use_contour_definition(
    threshold = 15,
    color = c(0, 0, 255),
    strokeWidth = 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_basemap()

if (interactive()) deck
# }

Run the code above in your browser using DataLab