add_terrain: Add terrain

Description Usage Arguments Details Examples

View source: R/map_layer_terrain.R

Description

Adds mesh surfaces from height map images

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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 elevation_data is a URL template, i.e. a string containing 'x' and 'y', it loads terrain tiles on demand and renders a mesh for each tile. If elevation_data is an absolute URL, as ingle mesh is used, and the bounds argument is required to position it into the world space.

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 ( c(left, bottom, right, top) . bounds of the image to fit in x,y coordinates into. left and right referes to the world longitude/x at the corresponding side of the image. top and bottom refers to the world latitude/y at the corresponding side of the image. Must be supplied when using non-tiled elevation_data

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

Each colour channel is a number between [0, 255].

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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
  )

mapdeck documentation built on Sept. 4, 2020, 9:07 a.m.