% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gdalraster_proc.R
\name{read_to_nativeRaster}
\alias{read_to_nativeRaster}
\title{Read raster data as nativeRaster}
\usage{
read_to_nativeRaster(
  ds,
  xoff = 0,
  yoff = 0,
  xsize = ds$getRasterXSize(),
  ysize = ds$getRasterYSize(),
  out_xsize = xsize,
  out_ysize = ysize
)
}
\arguments{
\item{ds}{An object of class \code{GDALRaster} in open state, with 1, 3, or 4
bands of Byte/UInt8 data type.}

\item{xoff}{Integer. The pixel (column) offset to the top left corner of the
raster region to be read (zero to start from the left side).}

\item{yoff}{Integer. The line (row) offset to the top left corner of the
raster region to be read (zero to start from the top).}

\item{xsize}{Integer. The width in pixels of the region to be read.}

\item{ysize}{Integer. The height in pixels of the region to be read.}

\item{out_xsize}{Integer. The width in pixels of the output buffer into
which the desired region will be read (e.g., to read a reduced resolution
overview).}

\item{out_ysize}{Integer. The height in pixels of the output buffer into
which the desired region will be read (e.g., to read a reduced resolution
overview).}
}
\value{
An object of class \code{nativeRaster}.
}
\description{
\code{read_to_nativeRaster()} will read from a raster dataset that is already open
in a \code{GDALRaster} object and return a \code{nativeRaster} object suitable for fast
rendering. By default, it attempts to read the full raster extent at full
resolution.
}
\details{
The dataset must have 1, 3, or 4 bands of Byte/UInt8 data type. For 1-band
(grayscale) data, the value is replicated across RGB channels. For 3-band
data, bands are interpreted as RGB. For 4-band data, bands are interpreted
as RGBA.
}
\note{
By default, this function will attempt to read the full raster into memory.
It generally should not be called on large raster datasets using the default
argument values. Use \code{out_xsize} and \code{out_ysize} for quick setting to smallish values,
such as 1024.
}
\examples{
# read an RGB image as nativeRaster
img_file <- system.file("help/figures/logo.png", package="survival")
if (file.exists(img_file)) {
ds <- new(GDALRaster, img_file)
r <- read_to_nativeRaster(ds)
bb <- ds$bbox()  ## will warn for non-spatial image but is harmless
ds$close()
plot(NA, xlab = "", ylab = "", asp = 1, xlim = bb[c(1, 3)], ylim = bb[c(2, 4)])
rasterImage(r, bb[1], bb[2], bb[3], bb[4])
}
}
\seealso{
\code{\link[=read_ds]{read_ds()}}, \code{\link[=GDALRaster]{GDALRaster$readToNativeRaster()}}
}
