data object for deckgl map visualization

Dear all

I am working with the deckgl package in R.

I want to visualize some data. Below I posted the default example from the package's github site.

I can see that the data for the add_grid_layer function has to be specified via a url link (in JS format??)

What is the easiest way for me to feed my own data to this function, when my data is currently in a data frame format?

Can someone share an example of using this function with a data object and not a URL?

Thank you kindly in advance. Have a good day.


Sys.setenv(MAPBOX_API_TOKEN = my_token)

deckgl() %>%
  add_mapbox_basemap(style = "mapbox://styles/mapbox/dark-v9")

# Grid layer example
sample_data <- paste0(
  "https://raw.githubusercontent.com/",
  "uber-common/deck.gl-data/",
  "master/website/sf-bike-parking.json"
)

properties <- list(
  pickable = TRUE,
  extruded = TRUE,
  cellSize = 200,
  elevationScale = 4,
  getPosition = JS("data => data.COORDINATES"),
  getTooltip = JS("object => object.count")
)

deckgl(zoom = 11, pitch = 45) %>%
  add_grid_layer(data = sample_data, properties = properties) %>%
  add_mapbox_basemap()

The way I did it was to use Notepad ++ to create a .json file.
I then converted it into an R ojbect using the fromJSON function in the jsonlite package.

In this way it worked, and the add_grid_layer function from the deckgl package recognized my data object.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.