Learn R Programming

rayshader (version 0.35.7)

generate_line_overlay: Generate Line Overlay

Description

Calculates and returns an overlay of lines for the current height map.

Usage

generate_line_overlay(
  geometry,
  extent,
  heightmap = NULL,
  width = NA,
  height = NA,
  color = "black",
  linewidth = 1,
  lty = 1,
  data_column_width = NULL,
  offset = c(0, 0)
)

Value

Semi-transparent overlay with contours.

Arguments

geometry

An `sf` object with LINESTRING geometry.

extent

Either an object representing the spatial extent of the scene (either from the `raster`, `terra`, `sf`, or `sp` packages), a length-4 numeric vector specifying `c("xmin", "xmax","ymin","ymax")`, or the spatial object (from the previously aforementioned packages) which will be automatically converted to an extent object.

heightmap

Default `NULL`. The original height map. Pass this in to extract the dimensions of the resulting overlay automatically.

width

Default `NA`. Width of the resulting overlay. Default the same dimensions as height map.

height

Default `NA`. Width of the resulting overlay. Default the same dimensions as height map.

color

Default `black`. Color of the lines.

linewidth

Default `1`. Line width.

lty

Default `1`. Line type. `1` is solid, `2` is dashed, `3` is dotted,`4` is dot-dash, `5` is long dash, and `6` is dash-long-dash.

data_column_width

Default `NULL`. The numeric column to map the width to. The maximum width will be the value specified in `linewidth`.

offset

Default `c(0,0)`. Horizontal and vertical offset to apply to the line, in units of `geometry`.

Examples

Run this code
#Add the included `sf` object with roads to the montereybay dataset
if(rayshader:::run_documentation()) {
water_palette = colorRampPalette(c("darkblue", "dodgerblue", "lightblue"))(200)
bathy_hs = height_shade(montereybay, texture = water_palette)
montereybay %>% 
 height_shade() %>%
 add_overlay(generate_altitude_overlay(bathy_hs, montereybay, 0, 0))  %>%
 add_overlay(generate_line_overlay(monterey_roads_sf, 
                                   attr(montereybay,"extent"), heightmap = montereybay))  %>%
 add_shadow(ray_shade(montereybay,zscale=50),0.3) %>%
 plot_map()
}
if(rayshader:::run_documentation()) {
#Change the line width, color, and transparency
montereybay %>%
 height_shade() %>%
 add_overlay(generate_altitude_overlay(bathy_hs, montereybay, 0, 0))  %>%
 add_overlay(generate_line_overlay(monterey_roads_sf, linewidth=3, color="white",
                                   attr(montereybay,"extent"), heightmap = montereybay),
                                   alphalayer=0.8)  %>%
 add_shadow(ray_shade(montereybay,zscale=50),0.3) %>%
 plot_map()
}
if(rayshader:::run_documentation()) {
#Manually specify the width and height to improve visual quality of the lines
montereybay %>%
 height_shade() %>%
 add_overlay(generate_altitude_overlay(bathy_hs, montereybay, 0, 0))  %>%
 add_shadow(ray_shade(montereybay,zscale=50),0.3) %>%
 add_overlay(generate_line_overlay(monterey_roads_sf, linewidth=3, color="white",
                                   attr(montereybay,"extent"), width = 1080, height = 1080),
                                   alphalayer=0.8)  %>%
 plot_map()
}

Run the code above in your browser using DataLab