Learn R Programming

voluModel (version 0.2.3)

interpolateRaster: Interpolate patchily sampled rasters

Description

Uses thin plate spline regression from fields package to interpolate missing two-dimensional raster values.

Usage

interpolateRaster(inputRaster, fast = FALSE, ...)

Value

An object of class raster

Arguments

inputRaster

An object of class SpatRaster

fast

A logical operator. Setting to TRUE triggers use of fastTps instead of Tps.

...

For any additional arguments passed to Tps or fastTps

Details

Missing data values from original raster are replaced with interpolated values. User has the option of choosing fastTps to speed calculation, but be advised that this is only an approximation of a true thin plate spline.

See Also

Tps, fastTps

Examples

Run this code
# \donttest{
library(terra)
library(fields)
# Create sample raster
r <- rast(ncol=50, nrow=50)
values(r) <- 1:2500

# Introduce a "hole"
values(r)[c(117:127, 167:177, 500:550)] <- NA
plot(r)

# Patch hole with interpolateRaster
interpolatedRaster <- interpolateRaster(r)
plot(interpolatedRaster)
fastInterp <- interpolateRaster(r, fast = TRUE, aRange = 3.0)
plot(fastInterp)
# }

Run the code above in your browser using DataLab