anusplin_make_param.RdFormat the input data and generate the configuration file required for ANUSPLIN interpolation.
anusplin_make_param(
dat,
basename,
range,
res = 0.25,
order = 3L,
unit = 0L,
width = 9,
missing = -9999L,
file.alt = NULL,
alt = c("cov", "spl"),
type.alt = "arcinfo_grid",
type.grd = "xyz",
type.mask = "none",
file.mask = NULL,
cvt.lon = c(0, 5),
cvt.lat = c(0, 5),
cvt.alt = c(1, 1),
cvt.coef = 1000,
trans.dep = 0,
err.wgt = 0,
optimize = 1,
smooth = 1,
...,
err.cov = 2,
grid.pos = 1,
essential = TRUE
)A data.frame or data.table to interpolate, for the colnames, lon, lat must be included, site and alt are optional, the others are variable names.
Basename for all output files, extensions should not be included.
Range of interpolation grid (xmin, xmax, ymin, ymax).
The grid resolution (degree).
(default 3L), order of spline, a positive integer.
The unit of dat, a non-negative integer, possible values are:
0: undefined (default)
1: meteres
2: feet
3: kilometers
4: miles
5: degrees
6: radians
7: millimetres
8: megajoules
The fixed width of numbers in formatted data.
Filling of missing values.
file path of alt
type.alt != "none": file.alt is file path
type.alt == "none": file.alt is a const real number
Type of elevation was treated, possible values are:
cov : considered as independent covariates (default)
spl : considered as independent spline variables
type of grid, one of c("const", "generic_grid", "arcinfo_grid", "idrisi_img"),
default arcinfo_grid
type of grid, one of c("xyz", "generic_grid", "arcinfo_grid", "idrisi_img"),
default arcinfo_grid
type of file.mask, one of c("none", "generic_grid",
"arcinfo_grid", "idrisi_img"), default arcinfo_grid`.
Filename of mask grid, only valid if type.mask set to positive
integer.
Transformation and scale factor (default is 1) of longitude.
Real Value = (Table Value) * (Scale Factor)
The possible transformations are:
0: no transformation (default)
1: x/a
2: ax
3: a·log(x+b)
4: (x/b)^a
5: a·exp(x/b)
6: a·tanh(x/b)
7: anisotropy angle in degrees
8: anisotropy factor - in the direction specified by the anisotropy angle
Same as cvt.lon, but for latitude.
Same as cvt.lon, but for altitude.
Parameters used for transformation, one or two real numbers.
Dependent variable transformation, possible values are:
0: no transformation (default)
1: fit surface to natural logarithm of the data values
2: fit surface to the square root of the data values
5: occurrence – transform data values by setting all positive value to 1.0 and ignoring all negative values
Number of relative error variances, a non-negative integer, possible values are:
0: data points uniformly weighted for each surface (default)
1: the same weighting is applied to each surface
Number of surfaces: a different weighting is applied to each surface
Optimization directive, a non-negative integer, possible values are:
0: common smoothing parameter for all surfaces
1: common smoothing directive for all surfaces (default)
2: different smoothing directive for each surface
Smoothing directive for each surface, a non-negative integer, possible values are:
0: fixed smoothing parameter - supply value
1: minimise GCV (default)
2: minimise true mean square error using supplied error standard deviation estimate
3: fixed signal - supply value
4: minimise GML
ignored.
test
Grid position option, a non-negative integer, possible values are:
0: grid points at cell corners
1: grid points at cell centres (default)
If True, only export essential process files, large residual
file, optimisation parameters file, data list file and validation data file are
ignored.
A vector containing lower and upper limits, auto (default)
meant to use the minimum and maximum values in the data, or set manually.
Data points outside these limits, augmented by margins, are ignored.
Same as lim.lon, but for longitude.
Same as lim.lon, but for altitude.
a list with three components:
data : formatted data.table of dat
splina : a vector containing splina parameters
lapgrd : a vector containing lapgrd parameters
none : not provided
xyz : grid written in X,Y,Z format
generic_grid : generic grid written by rows
arcinfo_grid : Arc/Info grid
idrisi_img : Idrisi image
if (FALSE) {
dat <- dat_RH[, .(lon, lat, alt, RH)]
X <- dat[, .(lon, lat, alt)] %>% as.matrix()
Y <- dat[, .(RH)] %>% as.matrix()
res <- 1
range <- c(70, 140, 15, 55)
r_dem <- get_chinadem(res = res) %>% round(1)
f_dem <- "output/dem.asc"
write_dem(r_dem, f_dem, digits = 1)
outdir <- "output"
anusplin_make_param(dat, "RH", range, res, file.alt = f_dem, cvt.coef = 1e3) -> param
anusplin_write_setting(param, outdir, is.run = TRUE, overwrite = TRUE)
anusplin_read_output(param$lapgrd, outdir) -> ans
ans
}