Plot the segments of a route as an elevation profile or cross-section. A geographic cross-section describes a two-dimensional cut through a route where the x-axis denotes the distance and the y-axis denotes the elevation. The area below the elevation profile can be used to plot an additional feature.
Usage
plot_section(
x,
feat = "avgspeed",
dist = "distance",
elev = "elevation",
palette = NULL,
scale_elevation = TRUE,
size = 1.5,
xlab = dist,
ylab = elev,
scale_title = feat,
title = NULL,
subtitle = NULL,
caption = NULL,
...
)
Arguments
- x
[sf]
An
sf
data.frame describing segments of a linestring. The data.frame is expected to have multiple rows (representing the segments) and at least three columns,"elevation"
,"distance"
and an additional feature. Preferably, this is a result ofors_inspect
, but othersf
data.frames might work as well.- dist, elev, feat
[character]
Column names of the distance, elevation and feature values inside
x
.- palette
[character]
Color palette to be used for plotting. Passed on to
scale_fill_manual
orscale_fill_gradientn
, depending on the data type offeat
. Defaults to the Cividis colormap.- scale_elevation
[logical]
Whether to scale the elevation axis based on the lowest elevation. If
FALSE
, the y-axis is not scaled and fixed at sea level. Defaults toTRUE
.- size
[numeric]
Size of the line plot. Defaults to
1.5
.[character]
Arguments to change label names, legend, title, subtitle and caption of the ggplot object.
- ...
Further arguments passed to
scale_fill_manual
orscale_fill_gradientn
depending on the data type offeat
.
Examples
if (FALSE) { # \dontrun{
sample <- ors_sample(2)
route <- ors_inspect(sample[1, ], sample[2, ], extra_info = TRUE)
plot_section(route, feat = "waytype")
plot_section(route, feat = "steepness", scale_elevation = FALSE)
zissou_pal <- hcl.colors(11, palette = "Zissou 1")
plot_section(route, "steepness", palette = zissou_pal)
terrain_pal <- hcl.colors(10, palette = "Terrain")
plot_section(route, "elevation", palette = terrain_pal, scale_elevation = FALSE)
} # }