Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

add_overlay

Add Overlay


Description

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

Usage

add_overlay(
  hillshade,
  overlay,
  alphacolor = NULL,
  alphamethod = "max",
  alphalayer = 1,
  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.

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'.

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'.

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

#Only run these examples if the `magick` package is installed.
if ("magick" %in% rownames(utils::installed.packages())) {
#Combining base R plotting with rayshader's spherical color mapping and raytracing:

montereybay %>%
  sphere_shade() %>%
  add_overlay(height_shade(montereybay),alphalayer = 0.6)  %>%
  add_shadow(ray_shade(montereybay,zscale=50)) %>%
  plot_map()



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

}

rayshader

Create Maps and Visualize Data in 2D and 3D

v0.24.10
GPL-3
Authors
Tyler Morgan-Wall
Initial release
2021-04-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.