add_geojson_layer: Add a geojson layer to the deckgl widget

View source: R/layers_geojson-layer.R

add_geojson_layerR Documentation

Add a geojson layer to the deckgl widget

Description

The GeoJsonLayer takes in GeoJson formatted data and renders it as interactive polygons, lines and points.

Usage

add_geojson_layer(
  deckgl,
  data = NULL,
  properties = list(),
  ...,
  id = "geojson-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/geojson-layer

Examples

geojson <- paste0(
  "https://raw.githubusercontent.com/",
  "uber-common/deck.gl-data/",
  "master/website/bart.geo.json"
)

deck <- deckgl(zoom = 10, pickingRadius = 5) %>%
  add_geojson_layer(
    data = geojson,
    filled = TRUE,
    extruded = TRUE,
    getRadius = 100,
    lineWidthScale = 20,
    lineWidthMinPixels = 2,
    getLineWidth = 1,
    getLineColor = "@=properties.color || 'green'",
    getFillColor = c(160, 160, 180, 200),
    getElevation = 30,
    tooltip = JS("object => object.properties.name || object.properties.station")
  ) %>%
  add_basemap()

if (interactive()) deck

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