Learn R Programming

GeoModels (version 2.2.2)

GeoVariogramDir: Empirical directional semivariogram

Description

Computes empirical semivariograms in multiple directions (e.g., 0, 45, 90, 135 degrees) to assess spatial anisotropy.

Usage

GeoVariogramDir(data, coordx, coordy = NULL, coordz = NULL,
                directions = c(0, 45, 90, 135), tolerance = 22.5, numbins = 13,
                maxdist = NULL, neighb = NULL, distance = "Eucl",
                subsample = 1)

Value

A list of class "GeoVariogramDir" with one element for each direction. Each element is a list with components:

centers

Centers of the distance bins.

gamma

Empirical semivariogram values for each bin.

npairs

Number of point pairs in each bin.

Arguments

data

A numeric vector containing the observed values at each location.

coordx

Spatial coordinates. Either a numeric vector giving the first coordinate, or a matrix with 2 (or 3) columns. If a matrix is provided, coordy and coordz are ignored.

coordy

A numeric vector of the second coordinate. Optional; defaults to NULL.

coordz

A numeric vector of the third coordinate (if needed). Optional; defaults to NULL.

directions

Numeric vector giving the principal directions (in degrees) for which the semivariogram is computed (default: c(0, 45, 90, 135)).

tolerance

Angular tolerance (in degrees) around each direction (default: 22.5).

numbins

Number of distance bins for the empirical semivariogram (default: 13).

maxdist

Maximum spatial distance to consider between pairs. If NULL, an internal default is used.

neighb

Number of nearest neighbors to use for each location. If NULL, an internal default is used.

distance

Type of distance metric to use (default: "Eucl"). See GeoFit for options.

subsample

Numeric in \((0,1]\). Proportion of spatial locations used to compute the directional semivariograms (useful for large datasets). Default is 1 (use all locations).

Details

The function computes empirical semivariograms for several directions by:

  • Selecting pairs of points within maxdist and among the neighb nearest neighbors using GeoNeighIndex.

  • Computing squared differences for each selected pair.

  • Assigning each pair to a directional class if the vector connecting the pair falls within the specified angular tolerance around a given direction.

  • Binning pairs by distance and computing the average squared difference (semivariogram) within each bin.

The direction is defined in the xy-plane even in 3D. For 2D data, set coordz = NULL.

The subsample argument can be used to reduce computational cost by randomly selecting a subset of spatial locations prior to pair construction. This is particularly useful for large datasets.

See Also

GeoVariogram, GeoNeighIndex

Examples

Run this code
require(GeoModels)
set.seed(960)
NN <- 2500
coords <- cbind(runif(NN), runif(NN))
scale <- 0.5/3
param <- list(mean = 0, sill = 1, nugget = 0, scale = scale, smooth = 0.5)
corrmodel <- "Matern"

set.seed(951)
data <- GeoSim(coordx = coords, corrmodel = corrmodel,
               model = "Gaussian", param = param)$data

vario_dir <- GeoVariogramDir(data = data, coordx = coords, maxdist = 0.4,
                             subsample = 0.5)

plot(vario_dir, ylim = c(0,1))

Run the code above in your browser using DataLab