Visualize height information and road attributes of linestring segments.
The linestrings must be a Simple Feature LINESTRING Z and are transformed to
GeoJSON. The function therefore inherits arguments from
addGeoJSON
.
addHeightgraph(
map,
data = NULL,
columns = NULL,
layerId = NULL,
group = NULL,
color = "#03F",
weight = 5,
opacity = 0.5,
dashArray = NULL,
smoothFactor = 1,
noClip = FALSE,
pathOpts = leaflet::pathOptions(),
options = heightgraphOptions()
)
a map widget object created from leaflet()
A Simple Feature LINESTRING with Z dimension.
A character vector of the columns you want to include in the heightgraph control
the layer id
the name of the group the newly created layers should belong to
(for clearGroup
and addLayersControl
purposes).
Human-friendly group names are permitted--they need not be short,
identifier-style names. Any number of layers and even different types of
layers (e.g. markers and polygons) can share the same group name.
stroke color
stroke width in pixels
stroke opacity (or layer opacity for tile layers)
a string that defines the stroke dash pattern
how much to simplify the polyline on each zoom level (more means better performance and less accurate representation)
whether to disable polyline clipping
List of further options for the path. See
pathOptions
List of further plugin options. See
heightgraphOptions
the new map
object
When used in Shiny, 3 events update a certain Shiny Input:
A click updates input$MAPID_heightgraph_click
A mouseover updates input$MAPID_heightgraph_mouseover
A mouseout updates input$MAPID_heightgraph_mouseout
If you want to explicitly remove the Heightgraph control, please use
removeControl
with the layerId = "hg_control"
.
Other Heightgraph Functions:
heightgraphOptions()
if (FALSE) {
library(leaflet)
library(leaflet.extras2)
library(sf)
data <- st_cast(st_as_sf(leaflet::atlStorms2005[4,]), "LINESTRING")
data <- st_transform(data, 4326)
data <- data.frame(st_coordinates(data))
data$elev <- runif(nrow(data), 10, 500)
data$L1 <- NULL
L1 <- round(seq.int(1, 4, length.out = nrow(data)))
data <- st_as_sf(st_sfc(lapply(split(data, L1), sfg_linestring)))
data <- st_as_sf(st_sfc(lapply(split(data, L1), function(x) {
st_linestring(as.matrix(x))
})))
data$steepness <- 1:nrow(data)
data$suitability <- nrow(data):1
data$popup <- apply(data, 1, function(x) {
sprintf("Steepness: %s<br>Suitability: %s", x$steepness, x$suitability)
})
leaflet() %>%
addTiles(group = "base") %>%
addHeightgraph(color = "red", columns = c("steepness", "suitability"),
opacity = 1, data = data, group = "heightgraph",
options = heightgraphOptions(width = 400))
}