Matrix to nativeRaster
matrix_to_nr(mat, palette, fill = "transparent", min = 0, max = 1, dst = NULL)
integer matrix
vector of colors. For an integer matrix, this palette must
contain at least as many colors as the maximum integer value in mat
.
For a numeric matrix, any length palette is allowed.
Color to be used for values < 1 when input is an integer matrix. Default: 'transparent'.
assumed range for the numeric data. values from the palette will be interpolated using this range as the extents. An error will occur if a value lies outside this range. Default: (0, 1)
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 <- colorfast::col_to_int(rainbow(12))
nr <- matrix_to_nr(m, palette)
plot(nr)