add_terrain {mapdeck} | R Documentation |
Add terrain
Description
Adds mesh surfaces from height map images
Usage
add_terrain(
map,
layer_id = NULL,
elevation_data,
texture = NULL,
elevation_decoder = c(1, 0, 0, 0),
bounds = NULL,
max_error = 4,
update_view = TRUE,
focus_layer = FALSE
)
Arguments
map |
a mapdeck map object |
layer_id |
single value specifying an id for the layer. Use this value to distinguish between shape layers of the same type. Layers with the same id are likely to conflict and not plot correctly |
elevation_data |
Image URL that encodes height data. When |
texture |
Image URL to use as the texture |
elevation_decoder |
Four value used to convert a pixel to elevation in metres. The values correspond to rScale, gScale, bScale, offset. See details |
bounds |
Four values ( |
max_error |
Martini error tolerance in metres, smaller number results in more detailed mesh. |
update_view |
logical indicating if the map should update the bounds to include this layer |
focus_layer |
logical indicating if the map should update the bounds to only include this layer |
Details
The elevation_decoder
contains four values representing
rScale - Multiplier of the red channel
gScale - Multiplier of the green channel
bScale - Multiplier of the blue channel
offset - translation of the sum
Each colour channel is a number between [0, 255].
Examples
set_token( "MAPBOX_TOKEN" )
## Digital elevation model from https://www.usgs.gov/
elevation <- 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/terrain.png'
texture <- 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/terrain-mask.png'
bounds <- c(-122.5233, 37.6493, -122.3566, 37.8159)
mapdeck() %>%
add_terrain(
, elevation_data = elevation
, elevation_decoder = c(1,0,0,0)
, texture = texture
, bounds = bounds
, max_error = 1
)