Matrix to nativeRaster
matrix_to_nr(mat, palette, dst = NULL)
integer matrix
vector of colors. This palette must contain at least as
many colors as the maximum integer value in mat
.
destination nativeRaster
object. If NULL (the default) a
new nativeRaster
will be created If a nativeRaster
is supplied here, it must have the exact dimensions to match the matrix
nativeRaster
m <- matrix(1:12, 3, 4)
palette <- str_cols_to_packed_cols(rainbow(12))
nr <- matrix_to_nr(m, palette)
plot(nr)