Use krig()
to krige soil data following the methodology of the John et al.
(2007). Features:
Tries to guess plotdim
.
Informs the guessed plotdim
and the gridsize
provided.
Allows to suppress messages.
Is vectorized over the argument var
, to easily iterate over multiple soil
variables.
Has a method for base::summary()
(see examples).
Has a method for tibble::as_tibble()
(see examples).
krig(soil, var, params = NULL, gridsize = 20, plotdim = NULL, breaks = krig_breaks(2, 320, 30), use_ksline = TRUE, quiet = FALSE)
soil | The data frame with the points, coords specified in the
columns |
---|---|
var | A character vector giving the name of each column in the soil dataset #' containing soil data to krige. |
params | If you want to pass specified kriging parameters; see
|
gridsize | Points are kriged to the center points of a grid of this size. |
plotdim | Numeric vector giving x and y dimensions of the plot. If
|
breaks | Breaks/intervals used to calculate the semivariogram. |
use_ksline | Use the |
quiet | Use |
A list with the following items:
df
: Data frame of kriged values (column z) at each grid point (x, y).
df.poly
: Data frame of the polynomial surface fitted to the raw data.
lambda
: The "lambda" value used in the Box-Cox transform of the raw
data.
vg
: A list giving the variogram parameters used for the kriging.
vm
: Minimum loss value returned from geoR::variofit()
.
krig()
evolves from GetKrigedSoil()
. GetKrigedSoil()
has been
deprecated, although it remains in the package as an internal function.
The default breaks argument is set to have more points where the exponential curve rises the most and fewer at large distances. This means that the curve fitting is not overly biased by points beyond the effective maximum range.
geoR::variofit()
, geoR::variog()
, geoR::as.geodata()
,
geoR::ksline()
, geoR::krige.conv()
, geoR::krige.control()
.
library(fgeo.tool)#> #>#>#> #>#>#> #>#>#> #> #> #> #> #> #> #> #> #> #> #> #> #> #> #> #> #> #> #> #> #> #> #> #> #>#> var: c #> df #> Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 1150 obs. of 3 variables: #> $ x: num 10 30 50 70 90 110 130 150 170 190 ... #> $ y: num 10 10 10 10 10 10 10 10 10 10 ... #> $ z: num 2.13 2.12 2.1 2.09 2.07 ... #> #> df.poly #> Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 1150 obs. of 3 variables: #> $ gx: num 10 30 50 70 90 110 130 150 170 190 ... #> $ gy: num 10 10 10 10 10 10 10 10 10 10 ... #> $ z : num 2.13 2.12 2.1 2.09 2.07 ... #> #> lambda #> 'numeric' #> num 1 #> #> vg #> 'variogram' #> List of 20 #> $ u : num [1:9] 60.9 86.5 103 122.7 146.1 ... #> $ v : num [1:9] 0.284 0.422 0.882 0.543 0.211 ... #> $ n : num [1:9] 7 9 10 10 18 19 36 34 38 #> $ sd : num [1:9] 0.414 0.48 0.633 0.501 0.405 ... #> $ bins.lim : num [1:31] 1.00e-12 2.00 2.38 2.84 3.38 ... #> $ ind.bin : logi [1:30] FALSE FALSE FALSE FALSE FALSE FALSE ... #> $ var.mark : num 0.317 #> $ beta.ols : num 1.36e-09 #> $ output.type : chr "bin" #> $ max.dist : num 320 #> $ estimator.type : chr "classical" #> $ n.data : int 30 #> $ lambda : num 1 #> $ trend : chr "cte" #> $ pairs.min : num 5 #> $ nugget.tolerance: num 1e-12 #> $ direction : chr "omnidirectional" #> $ tolerance : chr "none" #> $ uvec : num [1:30] 1 2.19 2.61 3.11 3.7 ... #> $ call : language variog(geodata = geodata, breaks = breaks, trend = trend, pairs.min = 5) #> #> vm #> 'variomodel', variofit' #> List of 17 #> $ nugget : num 0.352 #> $ cov.pars : num [1:2] 0 160 #> $ cov.model : chr "exponential" #> $ kappa : num 0.5 #> $ value : num 4.64 #> $ trend : chr "cte" #> $ beta.ols : num 1.36e-09 #> $ practicalRange : num 480 #> $ max.dist : num 320 #> $ minimisation.function: chr "optim" #> $ weights : chr "npairs" #> $ method : chr "WLS" #> $ fix.nugget : logi FALSE #> $ fix.kappa : logi TRUE #> $ lambda : num 1 #> $ message : chr "optim convergence code: 0" #> $ call : language variofit(vario = vg, ini.cov.pars = c(initialVal, startRange), cov.model = varModels[i], nugget = initialVal) #># Now using custom parameters (arbitrary but based on automated kriging params) params <- list( model = "circular", range = 100, nugget = 1000, sill = 46000, kappa = 0.5 ) # Also using not one but multiple soil variables vars <- c("c", "p") custom <- krig(soil_fake, vars, params = params, quiet = TRUE)#>summary(custom)#> var: c #> df #> Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 1150 obs. of 3 variables: #> $ x: num 10 30 50 70 90 110 130 150 170 190 ... #> $ y: num 10 10 10 10 10 10 10 10 10 10 ... #> $ z: num 2.29 2.31 2.22 2.04 1.79 ... #> #> df.poly #> Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 1150 obs. of 3 variables: #> $ gx: num 10 30 50 70 90 110 130 150 170 190 ... #> $ gy: num 10 10 10 10 10 10 10 10 10 10 ... #> $ z : num 2.13 2.12 2.1 2.09 2.07 ... #> #> lambda #> 'numeric' #> num 1 #> #> vg #> 'NULL' #> NULL #> #> vm #> 'NULL' #> NULL #> #> var: p #> df #> Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 1150 obs. of 3 variables: #> $ x: num 10 30 50 70 90 110 130 150 170 190 ... #> $ y: num 10 10 10 10 10 10 10 10 10 10 ... #> $ z: num 6.2 6.09 6.01 6.03 6.1 ... #> #> df.poly #> Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 1150 obs. of 3 variables: #> $ gx: num 10 30 50 70 90 110 130 150 170 190 ... #> $ gy: num 10 10 10 10 10 10 10 10 10 10 ... #> $ z : num 6.37 6.35 6.33 6.31 6.29 ... #> #> lambda #> 'numeric' #> num 1 #> #> vg #> 'NULL' #> NULL #> #> vm #> 'NULL' #> NULL #>#> # A tibble: 2,300 x 4 #> var x y z #> <chr> <dbl> <dbl> <dbl> #> 1 c 10 10 2.29 #> 2 c 30 10 2.31 #> 3 c 50 10 2.22 #> 4 c 70 10 2.04 #> 5 c 90 10 1.79 #> 6 c 110 10 1.54 #> 7 c 130 10 1.55 #> 8 c 150 10 1.64 #> 9 c 170 10 1.77 #> 10 c 190 10 1.89 #> # … with 2,290 more rows#> # A tibble: 6 x 4 #> var gx gy z #> <chr> <dbl> <dbl> <dbl> #> 1 p 890 450 5.84 #> 2 p 910 450 5.83 #> 3 p 930 450 5.82 #> 4 p 950 450 5.81 #> 5 p 970 450 5.81 #> 6 p 990 450 5.80