Add Deck.gl S2Layer to a mapgl::maplibre() or mapgl::mapboxgl() map using blazing fast nanoarrow::write_nanoarrow() data transfer.
Source: R/addGeoArrowS2Layer.R
addGeoArrowS2Layer.RdAdd Deck.gl S2Layer to a mapgl::maplibre() or mapgl::mapboxgl() map
using blazing fast nanoarrow::write_nanoarrow() data transfer.
Usage
addGeoArrowS2Layer(
map,
data,
source,
file,
url,
layer_id = "s2",
s2_column_name = "s2_cells",
popup = NULL,
tooltip = NULL,
render_options = renderOptions(),
data_accessors = dataAccessors(),
popup_options = popupOptions(),
tooltip_options = tooltipOptions(),
...
)Arguments
- map
the
mapgl::maplibre()ormapgl::mapboxgl()map to add the layer to.- data
a
sf,wk,geosorSpatVector(MULTI)POLYGONobject. Ignored ifsourceis supplied.- source
the
idof a source previously added viaaddSource().- file
a valid local file path to a
geoarroworgeoparquetfile to be added to the map. Ignored ifsourceordatais supplied.- url
a URL to a remotely hosted
geoarroworgeoparquetfile to be added to the map. Ignored ifsourceordataorfileis supplied.- layer_id
the layer id.
- s2_column_name
the name of the S2 cells column of the data object.
- popup
should a popup be contructed? If
TRUE, will create a popup fromm all available attributes of the feature. Can also be a character vector of column names, on which case the popup will include only those columns. If a single character is supplied, then this will be shown for all features. IfNULL(deafult) orFALSE, no popup will be shown.- tooltip
should a tooltip be contructed? If
TRUE, will create a tooltip fromm all available attributes of the feature. Can also be a character vector of column names, on which case the tooltip will include only those columns. If a single character is supplied, then this will be shown for all features. IfNULL(deafult) orFALSE, no tooltip will be shown.- render_options
a list of renderOptions
- data_accessors
a list of dataAccessors
- popup_options
a list of popupOptions
- tooltip_options
a list of tooltipOptions
- ...
can be used to pass additional props and parameters to the deck.gl instance. See Details for more info.
Details
... can be used to pass additional props and parameters to the deck.gl instance
for fine-tuning rendering behaviour. For example, we can pass a list called
parameters with settings that control the GPU pipeline of the deck.gl instance.
See https://luma.gl/docs/api-reference/core/parameters for a list of
available prarmeters.
By default, all deck.gl layers passed to a maplibre() map will be drawn on
top of existing ones. It is, however, possible to inject layers into the
existing maplibre (base) layer stack by using
render_options = renderOptions(beforeId = "<some-existing-layer-id>")
which will plot the current layer underneath "<some-existing-layer-id>".
See below for an example.
Examples
library(wk)
library(mapgl)
style_positron = "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"
m = maplibre(style = style_positron)
## single wk POLYGON
pl = wkt("POLYGON ((30 10, 10 30, 40 40, 30 10))")
m |>
addGeoArrowPolygonLayer(
data = pl
, render_options = renderOptions(
beforeId = "water"
)
)
## remote parquet file
## paste url together so CRAN check doesn't complain
base_url = "https://raw.githubusercontent.com/geoarrow/"
data_url = "geoarrow-data/v0.2.0/natural-earth/files/natural-earth_countries_native.parquet"
url = paste0(base_url, data_url)
m |>
addGeoArrowPolygonLayer(
url = url
, geom_column_name = "geometry"
, render_options = renderOptions(
extruded = FALSE
, stroked = TRUE
)
, popup = TRUE
, tooltip = TRUE
)