Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

resample

Transfer values of a SpatRaster to another one with a different geometry


Description

resample 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 crs are the same, you should consider using these other functions instead: aggregate, disaggregate, expand or crop.

Usage

## S4 method for signature 'SpatRaster,SpatRaster'
resample(x, y, method="bilinear", filename="", ...)

Arguments

x

SpatRaster to be resampleed

y

SpatRaster that x should be resampled to

method

character. Method used for estimating the new cell values. One of:

near: nearest neighbour. This method is fast, and the preferred method if the cell values represent classes. It is not a good choice for continuous values.

bilinear: bilinear interpolation. Default.

cubic: cubic interpolation.

cubicspline: cubic spline interpolation.

lanczos: Lanczos windowed sinc resampling.

filename

character. Output filename

...

additional arguments for writing files as in writeRaster

Value

SpatRaster

See Also

Examples

r <- rast(nrow=3, ncol=3, xmin=0, xmax=10, ymin=0, ymax=10)
values(r) <- 1:ncell(r)
s <- rast(nrow=25, ncol=30, xmin=1, xmax=11, ymin=-1, ymax=11)
x <- resample(r, s, method="bilinear")

opar <- par(no.readonly =TRUE)
par(mfrow=c(1,2))
plot(r)
plot(x)
par(opar)

terra

Spatial Data Analysis

v1.2-10
GPL (>= 3)
Authors
Robert J. Hijmans [cre, aut] (<https://orcid.org/0000-0001-5872-2872>), Roger Bivand [ctb] (<https://orcid.org/0000-0003-2392-6140>), Karl Forner [ctb], Jeroen Ooms [ctb] (<https://orcid.org/0000-0002-4035-0289>), Edzer Pebesma [ctb] (<https://orcid.org/0000-0001-8049-7069>)
Initial release
2021-05-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.