Join us for
RADAR: AI Edition

mapview (version 1.1.0)

rgb2spLayout: Convert an RGB RasterBrick/Stack to use with spplot

Description

This function takes a red-green-blue 'RasterStack' (or 'RasterBrick') object and produces a list with color information that can be passed on to the sp.layout argument from spplot.

Usage

rgb2spLayout(x, quantiles = c(0.02, 0.98), alpha = 1)

Arguments

x
a RasterBrick or RasterStack
quantiles
Upper and lower quantiles used for color stretching.
alpha
Level of transparency.

See Also

plotRGB

Examples

Run this code
library(raster)
library(sp)

b <- brick(system.file("external/rlogo.grd", package="raster"))

## using plotRGB
plotRGB(b)

## convert brick 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))
coordinates(df) <- ~x+y

## plot spatial points with rgb background
spplot(df, sp.layout = lout)
spplot(df, sp.layout = lout_alph)

Run the code above in your browser using DataLab