R/variog.R

Defines functions variogMcEnv.SpatVector variogMcEnv.default variogMcEnv variog.SpatVector variog.default variog

Documented in variog variog.default variogMcEnv variogMcEnv.default variogMcEnv.SpatVector variog.SpatVector

variog = function(geodata, ...) {
	UseMethod("variog")	
}

variog.default <- function(geodata, ...) {
	if (requireNamespace("geoR", quietly = TRUE)) { 
		result=geoR::variog(geodata, ...) 
	} else {
		result = NULL
	}
result
}
			
variog.SpatVector = function(geodata,formula, ...) {
	
  rownames(terra::values(geodata)) =  1:length(geodata)
  theCoords = crds(geodata)
  rownames(theCoords) = 1:length(geodata)
  
	theResid = lm(formula, data=values(geodata))$resid
 
	if (requireNamespace("geoR", quietly = TRUE)) { 
		
		result = geoR::variog(coords=theCoords[names(theResid),], 
        data=theResid, ...)
 
	} else {
		result = NULL
	}
	result
}


variogMcEnv = function(geodata, formula, ...) {
	UseMethod("variogMcEnv")
}

variogMcEnv.default = function(geodata, ...) {
	if (requireNamespace("geoR", quietly = TRUE)) { 
		result = geoR::variog.mc.env(geodata,...) 
	} else {
		result = NULL
	}
	result
}

variogMcEnv.SpatVector = function(geodata,formula, ...) {
  
  rownames(terra::values(geodata)) =  1:length(geodata)
  theCoords = crds(geodata)
  rownames(theCoords) = 1:length(geodata)
  
  
	theResid = lm(formula, data=values(geodata))$resid
	if (requireNamespace("geoR", quietly = TRUE)) { 
		result = geoR::variog.mc.env(coords=theCoords[names(theResid),], data=theResid, ...)
	} else {
			result = NULL
	}
result
}

Try the geostatsp package in your browser

Any scripts or data that you put into this service are public.

geostatsp documentation built on May 29, 2024, 5:53 a.m.