add_trips: Add Trips

Description Usage Arguments Details legend id Examples

View source: R/map_layer_trips.R

Description

The Trips Layer takes an sf object with Z (elevation) and M (time) attributes and renders it as animated trips

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
add_trips(
  map,
  data = get_map_data(map),
  stroke_colour = NULL,
  stroke_width = NULL,
  opacity = 0.3,
  palette = "viridis",
  trail_length = 180,
  start_time = get_m_range_start(data),
  end_time = get_m_range_end(data),
  animation_speed = 30,
  layer_id = NULL,
  legend = FALSE,
  legend_options = NULL,
  legend_format = NULL,
  digits = 6
)

Arguments

map

a mapdeck map object

data

sf object with XYZM dimensions.

stroke_colour

variable of data or hex colour for the stroke.

stroke_width

width of the stroke in meters. Default 1.

opacity

single value in [0,1]

palette

string or matrix. String will be one of colourvalues::colour_palettes(). A matrix must have at least 5 rows, and 3 or 4 columns of values between [0, 255], where the 4th column represents the alpha. You can use a named list to specify a different palette for different colour options (where available), e.g. list(fill_colour = "viridis", stroke_colour = "inferno")

trail_length

how long it takes for the trail to completely fade out (in same units as timestamps )

start_time

the minimum timestamp

end_time

the maximum timestamp

animation_speed

speed of animation

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

legend

either a logical indiciating if the legend(s) should be displayed, or a named list indicating which colour attributes should be included in the legend.

legend_options

A list of options for controlling the legend.

legend_format

A list containing functions to apply to legend values. See section legend

digits

number of digits for rounding coordinates

Details

add_trips supports LINESTRING and MULTILINESTRING sf objects

legend

The legend_options can be used to control the appearance of the legend. This should be a named list, where the names are one of

If the layer allows different fill and stroke colours, you can use different options for each. See examples in add_arc.

The legend_format can be used to control the format of the values in the legend. This should be a named list, where the names are one of

depending on which type of colouring the layer supports.

The list elements must be functions to apply to the values in the legend.

id

The id is returned to your R session from an interactive shiny environment by observing layer clicks. This is useful for returning the data.frame row relating to the cliked shape.

From within a shiny server you would typically use observeEvent({input$map_arc_click}), where 'map' is the map_id supplied to mapdeckOutput(), and 'arc' is the layer you are clicking on

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
set_token( "MAPBOX_TOKEN")
sf <- city_trail

mapdeck(
location = c(145, -37.8)
, zoom = 10
, style = mapdeck_style("dark")
) %>%
 add_trips(
   data = sf
   , animation_speed = 2000
   , trail_length = 1000
   , stroke_colour = "#FFFFFF"
)

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