Skip to contents

Plot a digital elevation profile based on xyz data

Usage

plot_dz(
  d,
  z,
  fill = TRUE,
  horiz = FALSE,
  pal = colorspace::diverging_hcl,
  ...,
  legend_position = "top",
  col = "black",
  cex = 0.9,
  bg = grDevices::rgb(1, 1, 1, 0.8),
  title = "Slope colors (percentage gradient)",
  brks = NULL,
  seq_brks = NULL,
  ncol = 4
)

Arguments

d

Cumulative distance

z

Elevations at points across a linestring

fill

Should the profile be filled? TRUE by default

horiz

Should the legend be horizontal (FALSE by default)

pal

Color palette to use, colorspace::diverging_hcl by default.

...

Additional parameters to pass to legend

legend_position

The legend position. One of "bottomright", "bottom", "bottomleft", "left", "topleft", "top" (the default), "topright", "right" and "center".

col

Line colour, black by default

cex

Legend size, 0.9 by default

bg

Legend background colour, grDevices::rgb(1, 1, 1, 0.8) by default.

title

Title of the legend, NULL by default.

brks

Breaks in colour palette to show. c(1, 3, 6, 10, 20, 40, 100) by default.

seq_brks

Sequence of breaks to show in legend. Includes negative numbers and omits zero by default

ncol

Number of columns in legend, 4 by default.

Value

A plot showing the elevation profile associated with a linestring.

Examples

library(sf)
route_xyz = lisbon_road_segment_3d
m = st_coordinates(route_xyz)
d = cumsum(sequential_dist(m, lonlat = FALSE))
d = c(0, d)
z = m[, 3]
slopes:::plot_dz(d, z, brks = c(3, 6, 10, 20, 40, 100))