Overlays an image (with a transparency layer) on the current map.

add_overlay(
  hillshade = NULL,
  overlay = NULL,
  alphalayer = 1,
  alphacolor = NULL,
  alphamethod = "max",
  rescale_original = FALSE
)

Arguments

hillshade

A three-dimensional RGB array or 2D matrix of shadow intensities.

overlay

A three or four dimensional RGB array, where the 4th dimension represents the alpha (transparency) channel. If the array is 3D, alphacolor should also be passed to indicate transparent regions.

alphalayer

Default 1. Defines minimum tranparaency of layer. If transparency already exists in overlay, the way add_overlay() combines the two is determined in argument alphamethod.

alphacolor

Default NULL. If overlay is a 3-layer array, this argument tells which color is interpretted as completely transparent.

alphamethod

Default max. Method for dealing with pre-existing transparency with layeralpha. If max, converts all alpha levels higher than layeralpha to the value set in layeralpha. Otherwise, this just sets all transparency to layeralpha.

rescale_original

Default FALSE. If TRUE, hillshade will be scaled to match the dimensions of overlay (instead of the other way around).

Value

Hillshade with overlay.

Examples

#Combining base R plotting with rayshader's spherical color mapping and raytracing:
if(run_documentation()) {
montereybay %>%
  sphere_shade() %>%
  add_overlay(height_shade(montereybay),alphalayer = 0.6)  %>%
  add_shadow(ray_shade(montereybay,zscale=50)) %>%
  plot_map()
}


if(run_documentation()) {
#Add contours with `generate_contour_overlay()`
montereybay %>%
  height_shade() %>%
  add_overlay(generate_contour_overlay(montereybay))  %>%
  add_shadow(ray_shade(montereybay,zscale=50)) %>%
  plot_map()
}