R: Calculate threshold, range, and nugget from a raster object

I need to calculate the threshold, range and nugget from the raster layer. I studied gstat, usdm packages where you can create a semivariogram, but I can not find a function that sets the raster layer, it will evaluate these parameters. In most functions, these parameters must be defined, for example. krigging.

I have raster data layers for different heights that look like enter image description here

I would like to get the threshold, nugget and range from the semi-variance parameters set on these data layers to create a graph like this: enter image description here

Source data layers are available here as multi-band tiff. Here is a figure from this document that once again illustrates the concept.

enter image description here

+7
r geospatial r-raster
source share
2 answers

Using gstat, here is an example:

library(raster) library(gstat) demo(meuse, ask = FALSE, echo = FALSE) set.seed(131) # make random numbers reproducible # add some noise with .1 variance meuse.grid$dist = meuse.grid$dist + rnorm(nrow(meuse.grid), sd=sqrt(.1)) r = raster(meuse.grid["dist"]) v = variogram(dist~1, as(r, "SpatialPixelsDataFrame")) (f = fit.variogram(v, vgm("Sph"))) # model psill range # 1 Nug 0.09035948 0.000 # 2 Sph 0.06709838 1216.737 f$psill[2] # sill # [1] 0.06709838 f$range[2] # range # [1] 1216.737 f$psill[1] # nugget # [1] 0.09035948 

Connect your own bitmap text for r and it should work. Change Sph to fit a different semivariogram model, try plot(v,f) to check the graph.

+3
source share

This is just an assumption. Here's how I rate half-difference

where n is the number of layers, their average is less than the total average. m is the total average value for all layers. r is the average value of each layer, which fell below the total average.

 s <- stack("old_gap_.tif") m <- cellStats(mean(s), stat="mean", na.rm=T) # 0.5620522 r <- m[m < 0.5620522] sem <- 1/53 * (0.5620522 - r)^2 plot(sem, r) 
+1
source share

All Articles