Skip to contents

Scales in tmap are configured by the family of functions with prefix tm_scale. Such function should be used for the input of the .scale arguments in the layer functions (e.g. fill.scale in tm_polygons()). The function tm_scale_rgb() is used to transform r, g, b band variables to colors. This function is adopted from (and works similar as) stars::st_rgb()

Usage

tm_scale_rgb(
  value.na = NA,
  stretch = FALSE,
  probs = c(0, 1),
  maxColorValue = 255L
)

tm_scale_rgba(
  value.na = NA,
  stretch = FALSE,
  probs = c(0, 1),
  maxColorValue = 255
)

Arguments

value.na

value for missing values

stretch

should each (r, g, b) band be stretched? Possible values: "percent" (same as TRUE) and "histogram". In the first case, the values are stretched to probs[1]...probs[2]. In the secodn case, a histogram equalization is performed

probs

probability (quantile) values when stretch = "percent"

maxColorValue

maximum value

Examples

require(stars)
file = system.file("tif/L7_ETMs.tif", package = "stars")

L7 = stars::read_stars(file)

tm_shape(L7) +
  tm_rgb(col.scale = tm_scale_rgb(probs = c(0, .99), stretch = TRUE))


tm_shape(L7) +
  tm_rgb(col.scale = tm_scale_rgb(stretch = "histogram"))