rgb2spLayout {Orcs} | R Documentation |
Convert an RGB Raster*
to Use with spplot()
Description
This function takes a red-green-blue SpatRaster
or Raster*
object and
produces a list with color information that can be passed on as 'sp.layout'
to sp::spplot()
.
Usage
rgb2spLayout(x, quantiles = c(0.02, 0.98), alpha = 1)
Arguments
x |
A 3-layered |
quantiles |
Upper and lower quantiles used for color stretching. |
alpha |
Level of transparency. |
Author(s)
Tim Appelhans, Florian Detsch
See Also
Examples
b = terra::rast(system.file("ex/logo.tif", package="terra"))
## using plotRGB
terra::plotRGB(b)
## convert raster to list
lout = rgb2spLayout(b)
lout_alph = rgb2spLayout(b, alpha = 0.5)
## create random spatial points for plotting
df = data.frame(
dat = rnorm(100, 2, 1)
, x = rnorm(100, 50, 20)
, y = rnorm(100, 50, 25)
)
df = sf::st_as_sf(df, coords = c("x", "y"))
## plot spatial points with rgb background
if (require(sp, quietly = TRUE)) {
spplot(as(df, "Spatial"), sp.layout = lout)
spplot(as(df, "Spatial"), sp.layout = lout_alph)
}
[Package Orcs version 1.2.3 Index]