Skip to contents

Thin extender over gstat::variogram that computes the sample (semi-)variogram of a spatially-indexed response for use in kriging and other geostatistical workflows.

Usage

morie_geostat_variogram(formula, data, ...)

Arguments

formula

A formula describing the response and any trend terms (e.g. z ~ 1 for an intercept-only model), as expected by gstat::variogram.

data

A spatial object (e.g. sp::SpatialPointsDataFrame or sf object) or data frame with coordinates available that gstat::variogram can consume.

...

Further arguments forwarded to gstat::variogram (e.g. cutoff, width, cressie, cloud).

Value

A list with $method = "gstat::variogram" and $raw (a gstatVariogram data frame with the binned distances and semivariance estimates).

Examples

# \donttest{
  if (requireNamespace("gstat", quietly = TRUE) &&
      requireNamespace("sp", quietly = TRUE)) {
    data(meuse, package = "sp")
    sp::coordinates(meuse) <- ~ x + y
    morie_geostat_variogram(log(zinc) ~ 1, data = meuse)
  }
#> $method
#> [1] "gstat::variogram"
#> 
#> $raw
#>     np       dist     gamma dir.hor dir.ver   id
#> 1   57   79.29244 0.1234479       0       0 var1
#> 2  299  163.97367 0.2162185       0       0 var1
#> 3  419  267.36483 0.3027859       0       0 var1
#> 4  457  372.73542 0.4121448       0       0 var1
#> 5  547  478.47670 0.4634128       0       0 var1
#> 6  533  585.34058 0.5646933       0       0 var1
#> 7  574  693.14526 0.5689683       0       0 var1
#> 8  564  796.18365 0.6186769       0       0 var1
#> 9  589  903.14650 0.6471479       0       0 var1
#> 10 543 1011.29177 0.6915705       0       0 var1
#> 11 500 1117.86235 0.7033984       0       0 var1
#> 12 477 1221.32810 0.6038770       0       0 var1
#> 13 452 1329.16407 0.6517158       0       0 var1
#> 14 457 1437.25620 0.5665318       0       0 var1
#> 15 415 1543.20248 0.5748227       0       0 var1
#> 
# }