% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gspace-misc.R
\name{as_colorraster}
\alias{as_colorraster}
\title{Map numeric values to a color raster}
\usage{
as_colorraster(x, palette = hcl.colors(30), na.color = "white")
}
\arguments{
\item{x}{A numeric vector or matrix containing values to be mapped to colors.}

\item{palette}{A vector of colors used as the palette. By default,
\code{hcl.colors(30)} is used.}

\item{na.color}{Color used for \code{NA} values. Defaults to \code{NA}.}
}
\value{
A raster object as produced by \code{as.raster()}.
}
\description{
Helper function that converts numeric values to colors and
returns a raster image. Useful for visualizing numeric matrices
as color backgrounds.
}
\details{
Values in \code{x} are rescaled to the range of the palette using
\code{scales::rescale()}, and each value is mapped to a corresponding
color. If \code{x} is a matrix, the resulting raster preserves the same
dimensions.
}
\examples{
# Convert the volcano matrix to a color raster
img <- as_colorraster(volcano)
plot(img)

}
