
Transfer values of a SpatRaster to another one with a different geometry
resample.Rdresample transfers values between SpatRaster objects that do not align (have a different origin and/or resolution). See project to change the coordinate reference system (crs).
If the origin and extent of the input and output are the same, you should consider using these other functions instead: aggregate, disagg, extend or crop.
Usage
# S4 method for class 'SpatRaster,SpatRaster'
resample(x, y, method, threads=FALSE, by_util=FALSE, filename="", ...)Arguments
- x
SpatRaster to be resampled
- y
SpatRaster with the geometry that
xshould be resampled to. You can also provide one or two positive numbers to set the resolution of the output raster relative to the input raster- method
character. Method used for estimating the new cell values. One of:
bilinear: bilinear interpolation (3x3 cell window). This is used by default if the first layer ofxis not categoricalmean: This can be a good choice with continuous variables if the output cells overlap with multiple input cells.near: nearest neighbor. This is used by default if the first layer ofxis categorical. This method is not a good choice for continuous values.modal: The modal value. This can be a good choice for categorical rasters, if the output cells overlap with multiple input cells.cubic: cubic interpolation (5x5 cell window).cubicspline: cubic B-spline interpolation. (5x5 cell window).lanczos: Lanczos windowed sinc resampling. (7x7 cell window).sum: the weighted sum of all non-NA contributing grid cells.min, q1, median, q3, max: the minimum, first quartile, median, third quartile, or maximum value.rms: the root-mean-square value of all non-NA contributing grid cells.- threads
logical. If
TRUEmultiple threads are used (faster for large files)- by_util
logical. If
TRUEthe GDAL warp utility is used- filename
character. Output filename
- ...
additional arguments for writing files as in
writeRaster
