Uses thin plate spline regression from
`fields`

package to interpolate missing two-dimensional
raster values.

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

- 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`

An object of class raster

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.

```
# \donttest{
library(terra)
library(fields)
#> Loading required package: spam
#> Spam version 2.10-0 (2023-10-23) is loaded.
#> Type 'help( Spam)' or 'demo( spam)' for a short introduction
#> and overview of this package.
#> Help for individual functions is also obtained by adding the
#> suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
#>
#> Attaching package: ‘spam’
#> The following objects are masked from ‘package:base’:
#>
#> backsolve, forwardsolve
#> Loading required package: viridisLite
#>
#> Try help(fields) to get started.
#>
#> Attaching package: ‘fields’
#> The following object is masked from ‘package:terra’:
#>
#> describe
# 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)
#> Warning:
#> Grid searches over lambda (nugget and sill variances) with minima at the endpoints:
#> (GCV) Generalized Cross-Validation
#> minimum at right endpoint lambda = 1.263526e-05 (eff. df= 160.55 )
plot(interpolatedRaster)
fastInterp <- interpolateRaster(r, fast = TRUE, aRange = 3.0)
plot(fastInterp)
# }
```