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

height_shade

Calculate Terrain Color Map


Description

Calculates a color for each point on the surface using a direct elevation-to-color mapping.

Usage

height_shade(
  heightmap,
  texture = (grDevices::colorRampPalette(c("#6AA85B", "#D9CC9A", "#FFFFFF")))(256),
  range = NULL,
  keep_user_par = TRUE
)

Arguments

heightmap

A two-dimensional matrix, where each entry in the matrix is the elevation at that point.

texture

Default 'terrain.colors(256)'. A color palette for the plot.

range

Default 'NULL', the full range of the heightmap. A length-2 vector specifying the maximum and minimum values to map the color palette to.

keep_user_par

Default ‘TRUE'. Whether to keep the user’s 'par()' settings. Set to 'FALSE' if you want to set up a multi-pane plot (e.g. set 'par(mfrow)').

Value

RGB array of hillshaded texture mappings.

Examples

#Create a direct mapping of elevation to color:
montereybay %>%
 height_shade() %>%
 plot_map()
 
#Add a shadow:

montereybay %>%
 height_shade() %>%
 add_shadow(ray_shade(montereybay,zscale=50),0.3) %>%
 plot_map()


#Change the palette:

montereybay %>%
 height_shade(texture = topo.colors(256)) %>%
 add_shadow(ray_shade(montereybay,zscale=50),0.3) %>%
 plot_map()


#Really change the palette:

montereybay %>%
 height_shade(texture = rainbow(256)) %>%
 add_shadow(ray_shade(montereybay,zscale=50),0.3) %>%
 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.