% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/conversion.R
\name{matrix_to_nr}
\alias{matrix_to_nr}
\title{Convert a numeric matrix to native raster image}
\usage{
matrix_to_nr(mat, palette, fill = "transparent", min = 0, max = 1, dst = NULL)
}
\arguments{
\item{mat}{integer matrix}

\item{palette}{vector of colors.  For an integer matrix, this palette must 
contain at least as many colors as the maximum integer value in \code{mat}. 
For a numeric matrix, any length palette is allowed, and the nearest
corresponding color is chosen (no interpolation is done).}

\item{fill}{Color to be used for values < 1 when input is an integer matrix.
Default: 'transparent'.}

\item{min, max}{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)}

\item{dst}{destination native raster image. If NULL (the default) a 
new native raster image will be created  If a native raster image 
is supplied here, it must have the exact dimensions to match the matrix}
}
\value{
native raster image
}
\description{
Convert a numeric matrix to native raster image
}
\examples{
# integer matrix
m <- matrix(1:12, 3, 4)
m
palette <- rainbow(12)
nr <- matrix_to_nr(m, palette) 
plot(nr)


# numeric matrix
m <- matrix(runif(20 * 30), 20, 30)
palette <- c('red', 'blue', 'black', 'green', 'blue', 'yellow')
nr <- matrix_to_nr(m, palette)
plot(nr)
}
\seealso{
Other conversion functions: 
\code{\link{magick_to_nr}()},
\code{\link{nr_to_raster}()},
\code{\link{nrs_to_gif}()},
\code{\link{nrs_to_mp4}()}
}
\concept{conversion functions}
