GeovariogramDir: Empirical Directional Semivariogram

GeoVariogramDirR Documentation

Empirical Directional Semivariogram

Description

Computes the empirical semivariogram in multiple directions (e.g., 0, 45, 90, 135 degrees) to assess spatial anisotropy, using only relevant pairs of points selected using maxdist and neighb through GeoNeighIndex.

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")

Arguments

data

A numeric vector containing the observed values at each location.

coordx

A numeric vector or matrix of the x-coordinates of the locations. If a matrix with 2 or 3 columns is provided, coordy and coordz are ignored.

coordy

A numeric vector of the y-coordinates of the locations. Optional; defaults to NULL for 1D data or if coordx is a matrix/data.frame.

coordz

A numeric vector of the z-coordinates of the locations. Optional; defaults to NULL for 2D data or if coordx is a matrix/data.frame with 2 columns.

directions

A numeric vector giving the principal directions (in degrees) for which to compute the semivariogram (default: c(0, 45, 90, 135)).

tolerance

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

numbins

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

maxdist

Maximum distance to consider between pairs (default: Inf).

neighb

Number of nearest neighbors to use for each location (default: length(data) - 1).

distance

Type of distance metric to use (default: "Eucl").

Details

The function computes the empirical semivariogram for several directions by:

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

  • Calculating the squared differences for each pair.

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

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

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

This implementation is optimized: distance bins and directional masks are precomputed for all pairs, minimizing repeated computations for each direction.

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.

See Also

GeoVariogram, GeoNeighIndex

Examples

require(GeoModels)
set.seed(960)
NN <- 1500
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)

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

GeoModels documentation built on June 8, 2025, 11:45 a.m.