% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gdalwarp_grid.R
\name{gdalwarp_grid}
\alias{gdalwarp_grid}
\title{Warp a raster file aligning it on the grid of another file}
\usage{
gdalwarp_grid(
  srcfiles,
  dstfiles,
  ref,
  of = NULL,
  r = NULL,
  dstnodata = NA,
  tmpdir = tempdir()
)
}
\arguments{
\item{srcfiles}{A vector of input file paths (managed by GDAL).}

\item{dstfiles}{A vector of input file paths.}

\item{ref}{Path of the raster taken as reference.}

\item{of}{The output format (use the short format name). Default is
the format of every input filename.}

\item{r}{Resampling_method (\code{"near"}|\code{"bilinear"}|\code{"cubic"}|\code{"cubicspline"}|
\code{"lanczos"}|\code{"average"}|\code{"mode"}|\code{"max"}|\code{"min"}|\code{"med"}|\code{"q1"}|\code{"q3"}).}

\item{dstnodata}{(optional) Set nodata values for output bands
(parameter passed to \code{gdalUtil()}).}

\item{tmpdir}{(optional) Path where intermediate files (.prj) will be created.
Default is a temporary directory.}
}
\value{
NULL (the function is called for its side effects)
}
\description{
The function applies \code{gdalwarp} to build rasters with the
same projection, resolution and grid alignment of another raster.
If not specified, the output format of each file is the same of the
corresponding source file.
}
\note{
License: GPL 3.0
}
\examples{
\donttest{
# Define file names
ex_sel <- system.file(
  "extdata/out/S2A2A_20190723_022_Barbellino_BOA_10.tif",
  package = "sen2r"
)
ex_ref <- system.file(
  "extdata/out/S2A2A_20190723_022_Barbellino_SCL_10.tif",
  package = "sen2r"
)
ex_out <- tempfile(fileext = "_BOA_out.tif")

# Run function
sen2r:::gdalwarp_grid(ex_sel, ex_out, ref = ex_ref)

# Show output
oldpar <- par(mfrow = c(1,3), mar = rep(0,4))
image(stars::read_stars(ex_sel), rgb = 4:2, maxColorValue = 3500, useRaster = TRUE)
par(mar = rep(2/3,4))
image(stars::read_stars(ex_ref), useRaster = TRUE)
par(mar = rep(0,4))
image(stars::read_stars(ex_out), rgb = 4:2, maxColorValue = 3500, useRaster = TRUE)
par(oldpar)
}
}
\references{
L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020).
"sen2r": An R toolbox for automatically downloading and preprocessing
Sentinel-2 satellite data. \emph{Computers & Geosciences}, 139, 104473.
\doi{10.1016/j.cageo.2020.104473}, URL: \url{https://sen2r.ranghetti.info/}.
}
\author{
Luigi Ranghetti, phD (2019)
}
\keyword{internal}
