Title: | An Extension of Package geoR that Works with Cost-Based Distances |
---|---|
Description: | Mainly, three functions are adapted in order to admit custom distance matrices as additional arguments. Namely variog, to produce empirical variograms; likfit, to fit theoretical variograms and krige.conv, to preform kriging. |
Authors: | Facundo Muñoz [aut, cre], Joseph Stachelek [ctb] |
Maintainer: | Facundo Muñoz <[email protected]> |
License: | GPL (>= 3) | file LICENSE |
Version: | 1.7-7 |
Built: | 2024-10-27 03:34:36 UTC |
Source: | https://github.com/famuvie/geoRcb |
Generate a cost-based distance matrix among observations and/or between observations and prediction locations.
distmatGen(pts, condsurf, ret = c("both", "obs", "loc"), directions = 16, silent = FALSE)
distmatGen(pts, condsurf, ret = c("both", "obs", "loc"), directions = 16, silent = FALSE)
pts |
A SpatialPoints[DataFrame] with a defined projection or a two-column data.frame/matrix of coordinates |
condsurf |
raster. Conductivity surface. |
ret |
specify whether to return distances between obs-obs ("obs"), obs-loc ("loc"), or both ("both") (default) |
directions |
See |
silent |
logical. If TRUE avoids any warnings or messages. |
Use the centroids of the conductivity or conductivity surface raster cells as prediction locations.
data(noise) if (require(raster)) { r <- raster(extent(c(0,3,0,3)), nrows = 3, ncols = 3) wall.idx <- 4:5 values(r)[-wall.idx] <- 1 obs <- coordinates(r)[-wall.idx, ] ddm <- distmatGen(obs, r, ret = "obs", directions = 8) par(mfrow = c(2, 1)) plot(r) text(obs[, 1], obs[, 2], col = c('red', rep('black', 6))) plot(dist(obs)[1:6], ddm[-1, 1], type = 'n', main = 'Distances to point 1', xlab = 'Euclidean distance', ylab = 'Cost-based distance') text(dist(obs)[1:6], ddm[-1, 1], labels = 2:7) abline(0, 1) }
data(noise) if (require(raster)) { r <- raster(extent(c(0,3,0,3)), nrows = 3, ncols = 3) wall.idx <- 4:5 values(r)[-wall.idx] <- 1 obs <- coordinates(r)[-wall.idx, ] ddm <- distmatGen(obs, r, ret = "obs", directions = 8) par(mfrow = c(2, 1)) plot(r) text(obs[, 1], obs[, 2], col = c('red', rep('black', 6))) plot(dist(obs)[1:6], ddm[-1, 1], type = 'n', main = 'Distances to point 1', xlab = 'Euclidean distance', ylab = 'Cost-based distance') text(dist(obs)[1:6], ddm[-1, 1], labels = 2:7) abline(0, 1) }
Default function to use with transition
. Defined as
the geometric mean.
geoR_trf(x)
geoR_trf(x)
x |
numeric vector of length 2 with cost/conductivity non-negative numbers. |
To use another function, override this one by defining it using the same name.
cost/conductivity value of the transition between neighbouring cells.
geoR_trf(c(0, 1)) # redefine function geoR_trf <- mean geoR_trf(c(0, 1))
geoR_trf(c(0, 1)) # redefine function geoR_trf <- mean geoR_trf(c(0, 1))
Defined as points whith cost distances to every other point of either 0 or Infinite.
idx_isol(x)
idx_isol(x)
param x distance matrix.
All the arguments work as in krige.conv
, except the
additional arguments dd.dists.mat
and dl.dists.mat
, which take
matrices of distances between observation locations and between observations
and prediction locations respectively
krige.conv(geodata, coords = geodata$coords, data = geodata$data, locations, borders, krige, output, dd.dists.mat, dl.dists.mat)
krige.conv(geodata, coords = geodata$coords, data = geodata$data, locations, borders, krige, output, dd.dists.mat, dl.dists.mat)
geodata |
a list containing elements |
coords |
an |
data |
a vector with n data values. By default it takes the
component |
locations |
an |
borders |
optional. By default reads the element |
krige |
a list defining the model components and the type of
kriging. It can take an output to a call to |
output |
a list specifying output options.
It can take an output to a call to |
dd.dists.mat |
n x n symmetric matrix with cost-based distances between observations |
dl.dists.mat |
m x n matrix with cost-based distances from each observation to each one of the m prediction locations |
## geodata structure with transformed covariates data(noise) if (require(sp)) { covarnames=sapply(1:3, function(x) paste("d2TV", x, sep="")) obs.df <- data.frame(Leq=obs$Leq, 1/(1+(as.data.frame(obs)[covarnames]/20)^2)) obs.gd <- as.geodata(cbind(coordinates(obs), obs.df), data.col="Leq", covar.col=c('d2TV1','d2TV2','d2TV3')) trend=~d2TV1*(d2TV2+d2TV3) loc1.df <- as.data.frame(1/(1+(as.data.frame(loc)[covarnames]/20)^2)) ## fitting variogram models vgmdl.std <- likfit(geodata = obs.gd, trend=trend, ini = c(8,300), cov.model = "matern") vgmdl.dmat <- likfit(geodata = obs.gd, trend=trend, ini = c(8,300), cov.model = "matern", dists.mat=dd.distmat) # With trend, Euclidean distances # NOTE: The Euclidean prediction is done with cost-based covariates KC.std = krige.control(trend.d=trend, trend.l=~loc1.df$d2TV1*(loc1.df$d2TV2+loc1.df$d2TV3), obj.model=vgmdl.std) kc1.std<-krige.conv(obs.gd,locations=coordinates(loc), krige=KC.std) # With trend, Cost-based distances KC = krige.control(trend.d=trend, trend.l=~loc1.df$d2TV1*(loc1.df$d2TV2+loc1.df$d2TV3), obj.model=vgmdl.dmat) kc1<-krige.conv(obs.gd,locations=coordinates(loc), krige=KC, dd.dists.mat=dd.distmat, dl.dists.mat=dl.distmat) }
## geodata structure with transformed covariates data(noise) if (require(sp)) { covarnames=sapply(1:3, function(x) paste("d2TV", x, sep="")) obs.df <- data.frame(Leq=obs$Leq, 1/(1+(as.data.frame(obs)[covarnames]/20)^2)) obs.gd <- as.geodata(cbind(coordinates(obs), obs.df), data.col="Leq", covar.col=c('d2TV1','d2TV2','d2TV3')) trend=~d2TV1*(d2TV2+d2TV3) loc1.df <- as.data.frame(1/(1+(as.data.frame(loc)[covarnames]/20)^2)) ## fitting variogram models vgmdl.std <- likfit(geodata = obs.gd, trend=trend, ini = c(8,300), cov.model = "matern") vgmdl.dmat <- likfit(geodata = obs.gd, trend=trend, ini = c(8,300), cov.model = "matern", dists.mat=dd.distmat) # With trend, Euclidean distances # NOTE: The Euclidean prediction is done with cost-based covariates KC.std = krige.control(trend.d=trend, trend.l=~loc1.df$d2TV1*(loc1.df$d2TV2+loc1.df$d2TV3), obj.model=vgmdl.std) kc1.std<-krige.conv(obs.gd,locations=coordinates(loc), krige=KC.std) # With trend, Cost-based distances KC = krige.control(trend.d=trend, trend.l=~loc1.df$d2TV1*(loc1.df$d2TV2+loc1.df$d2TV3), obj.model=vgmdl.dmat) kc1<-krige.conv(obs.gd,locations=coordinates(loc), krige=KC, dd.dists.mat=dd.distmat, dl.dists.mat=dl.distmat) }
All the arguments work as in likfit
, except the
additional argument dists.mat
, which takes a symmetric matrix of
distances between observation locations
likfit(geodata, coords = geodata$coords, data = geodata$data, trend = "cte", ini.cov.pars, fix.nugget = FALSE, nugget = 0, fix.kappa = TRUE, kappa = 0.5, fix.lambda = TRUE, lambda = 1, fix.psiA = TRUE, psiA = 0, fix.psiR = TRUE, psiR = 1, cov.model, realisations, lik.method = "ML", components = TRUE, nospatial = TRUE, limits = pars.limits(), dists.mat, print.pars = FALSE, messages, ...)
likfit(geodata, coords = geodata$coords, data = geodata$data, trend = "cte", ini.cov.pars, fix.nugget = FALSE, nugget = 0, fix.kappa = TRUE, kappa = 0.5, fix.lambda = TRUE, lambda = 1, fix.psiA = TRUE, psiA = 0, fix.psiR = TRUE, psiR = 1, cov.model, realisations, lik.method = "ML", components = TRUE, nospatial = TRUE, limits = pars.limits(), dists.mat, print.pars = FALSE, messages, ...)
geodata |
a list containing elements |
coords |
an |
data |
a vector with n data values. By default it takes the
component |
trend |
specifies the mean part of the model. See documentation
of |
ini.cov.pars |
initial values for the covariance parameters:
|
fix.nugget |
logical, indicating whether the parameter
|
nugget |
value of the nugget parameter.
Regarded as a fixed value if |
fix.kappa |
logical, indicating whether the extra parameter
|
kappa |
value of the extra parameter |
fix.lambda |
logical, indicating whether the Box-Cox transformation parameter
|
lambda |
value of the Box-Cox transformation parameter
|
fix.psiA |
logical, indicating whether the anisotropy angle parameter
|
psiA |
value (in radians) for the anisotropy angle parameter
|
fix.psiR |
logical, indicating whether the anisotropy ratio parameter
|
psiR |
value, always greater than 1, for the anisotropy ratio parameter
|
cov.model |
a string specifying the model for the correlation
function. For further details see documentation for |
realisations |
optional. Logical or a vector indicating the number of replication
for each datum. For further information see |
lik.method |
(formely method.lik) options are |
components |
an |
nospatial |
logical. If |
limits |
values defining lower and upper limits for the model
parameters used in the numerical minimisation.
The auxiliary function |
dists.mat |
n x n symmetric matrix with cost-based distances between observations |
print.pars |
logical. If |
messages |
logical. Indicates whether status messages should be printed on the screen (or output device) while the function is running. |
... |
additional parameters to be passed to the minimisation
function. Typically arguments of the type |
## geodata structure with transformed covariates data(noise) if (require(sp)) { covarnames=sapply(1:3, function(x) paste("d2TV", x, sep="")) obs.df <- data.frame(Leq=obs$Leq, 1/(1+(as.data.frame(obs)[covarnames]/20)^2)) obs.gd <- as.geodata(cbind(coordinates(obs), obs.df), data.col="Leq", covar.col=c('d2TV1','d2TV2','d2TV3')) trend=~d2TV1*(d2TV2+d2TV3) ## compute euclidean and cost-based empirical variograms vg.std <- variog(obs.gd, trend=trend) vg.dmat <- variog(obs.gd, trend=trend, dists.mat=dd.distmat) ## fitting variogram models vgmdl.std <- likfit(geodata = obs.gd, trend=trend, ini = c(8,300), cov.model = "matern") vgmdl.dmat <- likfit(geodata = obs.gd, trend=trend, ini = c(8,300), cov.model = "matern", dists.mat=dd.distmat) ## Fitted parameters data.frame( parameters=c("tausq","sigmasq","phi"), Euclidean=c(round(vgmdl.std$tausq,2),round(vgmdl.std$sigmasq,2),round(vgmdl.std$phi,0)), Cost_based=c(round(vgmdl.dmat$tausq,2),round(vgmdl.dmat$sigmasq,2),round(vgmdl.dmat$phi,0))) ## practical range ## defined as the value for which the correlation function ## decays to 5% of its value at 0 x=seq(0,800) y=cov.spatial(x,cov.pars=vgmdl.std$cov.pars) min(x[y<0.05*y[1]]) # 358 y=cov.spatial(x,cov.pars=vgmdl.dmat$cov.pars) min(x[y<0.05*y[1]]) # 502 # Note that the cost-based analysis detects a # longer-ranged correlation structure ## plotting and comparing empirical variograms ## (with classical and robust estimation) ## and fitted variogram models op <- par(mfrow=c(2,2)) u = 13 # binning for( est in c('classical','modulus') ) { vg.std <- variog(obs.gd, trend=trend, estimator.type=est, uvec=u) vg.dmat <- variog(obs.gd, trend=trend, dists.mat=dd.distmat, estimator.type=est, uvec=u) plot(vg.std,pch=20, cex=1.2, max.dist=max(vg.dmat$u), ylim=c(0,20), col='gray') lines(vg.std,pch=20, col='gray') lines(vg.dmat,pch=20,cex=2,col='red') legend('topleft',c('Euclidean','Cost'),lty=1,lwd=2,col=c('gray','red')) title(paste('binning:',u,' estimator:',est)) plot(vg.std, pch=20, cex=1.2, max.dist=800, col='gray') # empirical standard lines(vgmdl.std,lwd=2,col='gray') # fitted model standard points(as.data.frame(vg.dmat[c(1,2)]),pch=20,cex=2,col='red') # empirical cost-based lines(vgmdl.dmat,lwd=2,col='darkred') # fitted model cost-based legend('topleft',c('Euclidean','Cost'),lty=1,lwd=2,col=c('gray','red')) title(paste('binning:',u,' estimator:',est)) } par(op) }
## geodata structure with transformed covariates data(noise) if (require(sp)) { covarnames=sapply(1:3, function(x) paste("d2TV", x, sep="")) obs.df <- data.frame(Leq=obs$Leq, 1/(1+(as.data.frame(obs)[covarnames]/20)^2)) obs.gd <- as.geodata(cbind(coordinates(obs), obs.df), data.col="Leq", covar.col=c('d2TV1','d2TV2','d2TV3')) trend=~d2TV1*(d2TV2+d2TV3) ## compute euclidean and cost-based empirical variograms vg.std <- variog(obs.gd, trend=trend) vg.dmat <- variog(obs.gd, trend=trend, dists.mat=dd.distmat) ## fitting variogram models vgmdl.std <- likfit(geodata = obs.gd, trend=trend, ini = c(8,300), cov.model = "matern") vgmdl.dmat <- likfit(geodata = obs.gd, trend=trend, ini = c(8,300), cov.model = "matern", dists.mat=dd.distmat) ## Fitted parameters data.frame( parameters=c("tausq","sigmasq","phi"), Euclidean=c(round(vgmdl.std$tausq,2),round(vgmdl.std$sigmasq,2),round(vgmdl.std$phi,0)), Cost_based=c(round(vgmdl.dmat$tausq,2),round(vgmdl.dmat$sigmasq,2),round(vgmdl.dmat$phi,0))) ## practical range ## defined as the value for which the correlation function ## decays to 5% of its value at 0 x=seq(0,800) y=cov.spatial(x,cov.pars=vgmdl.std$cov.pars) min(x[y<0.05*y[1]]) # 358 y=cov.spatial(x,cov.pars=vgmdl.dmat$cov.pars) min(x[y<0.05*y[1]]) # 502 # Note that the cost-based analysis detects a # longer-ranged correlation structure ## plotting and comparing empirical variograms ## (with classical and robust estimation) ## and fitted variogram models op <- par(mfrow=c(2,2)) u = 13 # binning for( est in c('classical','modulus') ) { vg.std <- variog(obs.gd, trend=trend, estimator.type=est, uvec=u) vg.dmat <- variog(obs.gd, trend=trend, dists.mat=dd.distmat, estimator.type=est, uvec=u) plot(vg.std,pch=20, cex=1.2, max.dist=max(vg.dmat$u), ylim=c(0,20), col='gray') lines(vg.std,pch=20, col='gray') lines(vg.dmat,pch=20,cex=2,col='red') legend('topleft',c('Euclidean','Cost'),lty=1,lwd=2,col=c('gray','red')) title(paste('binning:',u,' estimator:',est)) plot(vg.std, pch=20, cex=1.2, max.dist=800, col='gray') # empirical standard lines(vgmdl.std,lwd=2,col='gray') # fitted model standard points(as.data.frame(vg.dmat[c(1,2)]),pch=20,cex=2,col='red') # empirical cost-based lines(vgmdl.dmat,lwd=2,col='darkred') # fitted model cost-based legend('topleft',c('Euclidean','Cost'),lty=1,lwd=2,col=c('gray','red')) title(paste('binning:',u,' estimator:',est)) } par(op) }
Same as geoR's loglik.GRF
but taking into account non-Euclidean
distances if pertinent.
loglik.GRF(geodata, coords = geodata$coords, data = geodata$data, obj.model = NULL, cov.model = "exp", cov.pars, nugget = 0, kappa = 0.5, lambda = 1, psiR = 1, psiA = 0, trend = "cte", method.lik = "ML", compute.dists = TRUE, realisations = NULL)
loglik.GRF(geodata, coords = geodata$coords, data = geodata$data, obj.model = NULL, cov.model = "exp", cov.pars, nugget = 0, kappa = 0.5, lambda = 1, psiR = 1, psiA = 0, trend = "cte", method.lik = "ML", compute.dists = TRUE, realisations = NULL)
geodata |
a list containing elements |
coords |
an |
data |
a vector with data values. By default it takes the
element |
obj.model |
a object of the class |
cov.model |
a string specifying the model for the correlation
function. For further details see
documentation for |
cov.pars |
a vector with 2 elements with values of the covariance parameters
|
nugget |
value of the nugget parameter. Defaults to |
kappa |
value of the smoothness parameter. Defaults to
|
lambda |
value of the Box-Cox tranformation parameter. Defaults
to |
psiR |
value of the anisotropy ratio parameter. Defaults to
|
psiA |
value (in radians) of the anisotropy rotation parameter. Defaults to zero. |
trend |
specifies the mean part of the model.
The options are:
|
method.lik |
options are |
compute.dists |
for internal use with other function. Don't change the default unless you know what you are doing. |
realisations |
optional. A vector indicating replication number
for each data. For more details see |
Noise measurements, cartography and cost-based distance matrices from a pilot-study in Valencia, Spain (see reference).
Antonio López-Quílez and Facundo Muñoz (2009). Geostatistical computing of acoustic maps in the presence of barriers. Mathematical and Computer Modelling 50(5-6): 929–938. DOI:10.1016/j.mcm.2009.05.021
data(noise) if (require(sp)) { plot(malilla) points(obs, pch=19, col='red') ## geodata structure with transformed covariates covarnames=sapply(1:3, function(x) paste("d2TV", x, sep="")) obs1.df <- as.data.frame(cbind(Leq=obs$Leq, 1/(1+(as.data.frame(obs)[covarnames]/20)^2))) obs.gd <- as.geodata(cbind(coordinates(obs), obs1.df), data.col="Leq", covar.col=c('d2TV1','d2TV2','d2TV3')) plot(obs.gd) }
data(noise) if (require(sp)) { plot(malilla) points(obs, pch=19, col='red') ## geodata structure with transformed covariates covarnames=sapply(1:3, function(x) paste("d2TV", x, sep="")) obs1.df <- as.data.frame(cbind(Leq=obs$Leq, 1/(1+(as.data.frame(obs)[covarnames]/20)^2))) obs.gd <- as.geodata(cbind(coordinates(obs), obs1.df), data.col="Leq", covar.col=c('d2TV1','d2TV2','d2TV3')) plot(obs.gd) }
Same as geoR's varcov.spatial
, but taking into account
non-Euclidean distances if pertinent.
varcov.spatial(coords = NULL, dists.lowertri = NULL, cov.model = "matern", kappa = 0.5, nugget = 0, cov.pars = stop("no cov.pars argument"), inv = FALSE, det = FALSE, func.inv = c("cholesky", "eigen", "svd", "solve"), scaled = FALSE, only.decomposition = FALSE, sqrt.inv = FALSE, try.another.decomposition = TRUE, only.inv.lower.diag = FALSE, ...)
varcov.spatial(coords = NULL, dists.lowertri = NULL, cov.model = "matern", kappa = 0.5, nugget = 0, cov.pars = stop("no cov.pars argument"), inv = FALSE, det = FALSE, func.inv = c("cholesky", "eigen", "svd", "solve"), scaled = FALSE, only.decomposition = FALSE, sqrt.inv = FALSE, try.another.decomposition = TRUE, only.inv.lower.diag = FALSE, ...)
coords |
an |
dists.lowertri |
a vector with the lower triangle of the matrix
of distances between pairs of data points. If not provided
the argument |
cov.model |
a string indicating the type of the correlation
function. More details in the
documentation for |
kappa |
values of the additional smoothness parameter, only required by
the following correlation
functions: |
nugget |
the value of the nugget parameter |
cov.pars |
a vector with 2 elements or an |
inv |
if |
det |
if |
func.inv |
algorithm used for the decomposition and inversion of the covariance
matrix. Options are |
scaled |
logical indicating whether the covariance matrix should
be scaled. If |
only.decomposition |
logical. If |
sqrt.inv |
if |
try.another.decomposition |
logical. If |
only.inv.lower.diag |
logical. If |
... |
for naw, only for internal usage. |
All the arguments work as in variog
, except the
additional argument dists.mat
, which takes a symmetric matrix of
distances between observation locations
variog(geodata, coords = geodata$coords, data = geodata$data, uvec = "default", breaks = "default", trend = "cte", lambda = 1, option = c("bin", "cloud", "smooth"), estimator.type = c("classical", "modulus"), nugget.tolerance, max.dist, pairs.min = 2, bin.cloud = FALSE, direction = "omnidirectional", tolerance = pi/8, unit.angle = c("radians", "degrees"), angles = FALSE, dists.mat, messages, ...)
variog(geodata, coords = geodata$coords, data = geodata$data, uvec = "default", breaks = "default", trend = "cte", lambda = 1, option = c("bin", "cloud", "smooth"), estimator.type = c("classical", "modulus"), nugget.tolerance, max.dist, pairs.min = 2, bin.cloud = FALSE, direction = "omnidirectional", tolerance = pi/8, unit.angle = c("radians", "degrees"), angles = FALSE, dists.mat, messages, ...)
geodata |
a list containing element |
coords |
an |
data |
a vector or matrix with data values.
If a matrix is provided, each column is regarded as one variable or realization.
Defaults to |
uvec |
a vector with values used to define the variogram binning. Only
used when |
breaks |
a vector with values to define the variogram binning. Only
used when |
trend |
specifies the mean part of the model.
See documentation of |
lambda |
values of the Box-Cox transformation parameter.
Defaults to |
option |
defines the output type: the options |
estimator.type |
|
nugget.tolerance |
a numeric value. Points which are separated by a distance less than this value are considered co-located. Defaults to zero. |
max.dist |
a numerical value defining the maximum distance for the variogram. Pairs of locations separated for distance larger than this value are ignored for the variogram calculation. If not provided defaults takes the maximum distance among all pairs of data locations. |
pairs.min |
a integer number defining the minimum numbers of
pairs for the bins.
For |
bin.cloud |
logical. If |
direction |
a numerical value for the directional (azimuth) angle. This
used to specify directional variograms. Default defines the
omnidirectional variogram. The value must be in the interval
|
tolerance |
numerical value for the tolerance angle, when
computing directional variograms. The value must be in the interval
|
unit.angle |
defines the unit for the specification of angles in
the two previous arguments. Options are |
angles |
Logical with default to |
dists.mat |
n x n symmetric matrix with cost-based distances between observations |
messages |
logical. Indicates whether status messages should be printed on the screen (or output device) while the function is running. |
... |
arguments to be passed to the function |
## geodata structure with transformed covariates data(noise) if (require(sp)) { covarnames=sapply(1:3, function(x) paste("d2TV", x, sep="")) obs.df <- data.frame(Leq=obs$Leq, 1/(1+(as.data.frame(obs)[covarnames]/20)^2)) obs.gd <- as.geodata(cbind(coordinates(obs), obs.df), data.col="Leq", covar.col=c('d2TV1','d2TV2','d2TV3')) ## compute euclidean and cost-based empirical variograms vg.std <- variog(obs.gd, trend=~d2TV1*(d2TV2+d2TV3)) vg.dmat <- variog(obs.gd, trend=~d2TV1*(d2TV2+d2TV3), dists.mat=dd.distmat) ## plot and compare empirical variograms plot(vg.std, type = 'l', col = 'darkred', main = 'Euclidean (red) vs. cost-based (gray) empirical variograms') lines(vg.dmat, type = 'l', col = 'darkgray') }
## geodata structure with transformed covariates data(noise) if (require(sp)) { covarnames=sapply(1:3, function(x) paste("d2TV", x, sep="")) obs.df <- data.frame(Leq=obs$Leq, 1/(1+(as.data.frame(obs)[covarnames]/20)^2)) obs.gd <- as.geodata(cbind(coordinates(obs), obs.df), data.col="Leq", covar.col=c('d2TV1','d2TV2','d2TV3')) ## compute euclidean and cost-based empirical variograms vg.std <- variog(obs.gd, trend=~d2TV1*(d2TV2+d2TV3)) vg.dmat <- variog(obs.gd, trend=~d2TV1*(d2TV2+d2TV3), dists.mat=dd.distmat) ## plot and compare empirical variograms plot(vg.std, type = 'l', col = 'darkred', main = 'Euclidean (red) vs. cost-based (gray) empirical variograms') lines(vg.dmat, type = 'l', col = 'darkgray') }
If there is a custom definicion of distances, it uses it. Otherwise, it computes the reciprocal distances of points in x.
vecdist(x)
vecdist(x)
x |
a |
If there exists a matrix object named
.personal.definition.of.distances
in the global environment, the
function returns the lower triangular part of it as a vector, regardless of
x
. Otherwise, the Euclidean distances between points in x
are
returned as a vector.