stars (version 0.4-3)

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 = FALSE, maxColorValue = 255)

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

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

st_apply, rgb

Examples

Run this code
# NOT RUN {
tif = system.file("tif/L7_ETMs.tif", package = "stars")
x = read_stars(tif)
st_rgb(x, 3)
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()
}
# }

Run the code above in your browser using DataLab