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

st_rgb

reduce dimension to rgb (alpha) hex values


Description

reduce dimension to rgb (alpha) hex values

Usage

st_rgb(
  x,
  dimension = 3,
  use_alpha = dim(x)[dimension] == 4,
  maxColorValue = 255L,
  probs = c(0, 1),
  stretch = FALSE
)

Arguments

x

object of class stars

dimension

dimension name or number to reduce

use_alpha

logical; if TRUE, the fourth band will be used as alpha values

maxColorValue

integer; maximum value for colors

probs

probability values for quantiles used for stretching

stretch

logical; if TRUE, each band is stretched to 0 ... maxColorValue

Details

the dimension's bands are mapped to red, green, blue, alpha; if a different ordering is wanted, use [.stars to reorder a dimension, see examples

See Also

Examples

tif = system.file("tif/L7_ETMs.tif", package = "stars")
x = read_stars(tif)
st_rgb(x[,,,3:1])
r = st_rgb(x[,,,c(6,5,4,3)], 3, use_alpha=TRUE) # now R=6,G=5,B=4,alpha=3
if (require(ggplot2)) {
 ggplot() + geom_stars(data = r) + scale_fill_identity()
}

stars

Spatiotemporal Arrays, Raster and Vector Data Cubes

v0.5-2
Apache License
Authors
Edzer Pebesma [aut, cre] (<https://orcid.org/0000-0001-8049-7069>), Michael Sumner [ctb] (<https://orcid.org/0000-0002-2471-7511>), Etienne Racine [ctb], Adriano Fantini [ctb], David Blodgett [ctb]
Initial release

We don't support your browser anymore

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