st_rgb | R Documentation |
reduce dimension to rgb (alpha) hex values
st_rgb(
x,
dimension = 3,
use_alpha = dim(x)[dimension] == 4,
maxColorValue = 255L,
probs = c(0, 1),
stretch = NULL
)
x |
object of class |
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 by "percent". |
stretch |
logical or character; if |
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.
Alternatively, you can use plot.stars with the rgb
argument to create a three-band composition.
st_apply, rgb
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()
}
r = st_rgb(x[,,,3:1],
probs = c(0.01, 0.99),
stretch = "percent")
plot(r)
r = st_rgb(x[,,,3:1],
probs = c(0.01, 0.99),
stretch = "histogram")
plot(r)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.