Thin plate spline regression

tps(
  .data,
  var,
  resolution = 0.5,
  land_borders = rnaturalearth::ne_countries(scale = "small", returnclass = "sf"),
  check_data = TRUE,
  z_var = NULL,
  z_mode = "independent",
  z_ref = NULL,
  cpus = 1,
  ...
)

Arguments

.data

Data frame with spatial and climate data. The following are expected:

  • Latitude, named: latitude, lat or y.

  • Longitude, named: longitude, long, lon or y.

  • Main variable, named: value of var.

var

String with the name of the climate variable to interpolate.

resolution

Numeric value with the resolution (degrees) to interpolate.

land_borders

Data frame with polygons to represent land borders (e.g. continents, countries, counties, etc.). Default: rnaturalearth::ne_countries.

check_data

Boolean flag to indicate whether .data should be checked or not (i.e. validate coordinates and main variable). Default: TRUE

z_var

String with the name of the variable containing information for elevation. If this is given, then the elevation is used for the interpolation.

z_mode

String with the mode in which the elevation should be used:

  • z_mode = "independent" (Default), use the elevation as another independent variable to predict var.

  • z_mode = "covariate", use the elevation as a linear covariate to predict var.

z_ref

Raster object or path to raster object with grid containing elevation information. For example the ETOPO5 (Earth topography 5 arc minute) data set.

cpus

Numeric value with the number of CPUs to use in the computation of the elevations for the interpolation grid.

...

Arguments passed on to fields::Tps

m

A polynomial function of degree (m-1) will be included in the model as the drift (or spatial trend) component. Default is the value such that 2m-d is greater than zero where d is the dimension of x.

p

Polynomial power for Wendland radial basis functions. Default is 2m-d where d is the dimension of x.

scale.type

The independent variables and knots are scaled to the specified scale.type. By default the scale type is "range", whereby the locations are transformed to the interval (0,1) by forming (x-min(x))/range(x) for each x. Scale type of "user" allows specification of an x.center and x.scale by the user. The default for "user" is mean 0 and standard deviation 1. Scale type of "unscaled" does not scale the data.

method

Determines what "smoothing" parameter should be used. The default is to estimate standard GCV Other choices are: GCV.model, GCV.one, RMSE, pure error and REML. The differences are explained in the Krig help file.

GCV

If TRUE the decompositions are done to efficiently evaluate the estimate, GCV function and likelihood at multiple values of lambda.

miles

If TRUE great circle distances are in miles if FALSE distances are in kilometers

Value

tibble object with interpolated values.