Examples for 'stars::st_rgb'


reduce dimension to rgb (alpha) hex values

Aliases: st_rgb

Keywords:

### ** Examples

tif = system.file("tif/L7_ETMs.tif", package = "stars")
x = read_stars(tif)
st_rgb(x[,,,3:1])
stars object with 2 dimensions and 1 attribute
attribute(s):
 L7_ETMs.tif       
 Length:122848     
 Class :character  
 Mode  :character  
dimension(s):
  from  to  offset delta                     refsys point x/y
x    1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x]
y    1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y]
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()
}
Loading required package: ggplot2
plot of chunk example-stars-st_rgb-1
r = st_rgb(x[,,,3:1],
                   probs = c(0.01, 0.99),
                   stretch = "percent")
plot(r)
plot of chunk example-stars-st_rgb-1
r = st_rgb(x[,,,3:1],
                   probs = c(0.01, 0.99),
                   stretch = "histogram")
plot(r)
plot of chunk example-stars-st_rgb-1

[Package stars version 0.6-7 Index]