Created
September 20, 2016 13:08
-
-
Save mikebirdgeneau/5b73a0c543a1e37fd5189d78a22f3dfa to your computer and use it in GitHub Desktop.
3D Kriging with Conditional Gaussian Simulation in R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(gstat) | |
library(lattice) | |
# Create Data Points (Random) | |
n <- 50 | |
data3D <- data.frame(x = runif(n), y = runif(n), z = runif(n), v = rnorm(n)) | |
coordinates(data3D) = ~x+y+z | |
# Create empty grid to krige | |
range1D <- seq(from = 0, to = 1, length = 20) | |
grid3D <- expand.grid(x = range1D, y = range1D, z = range1D) | |
gridded(grid3D) = ~x+y+z | |
# Perform CGS with 10 realizations; maxdist & nmax important for speed of calculation. | |
res3D <- krige(formula = v ~ 1, data3D, grid3D, model = vgm(1, "Exp", .2),nsim=10,maxdist=10,nmax=9) | |
# Plot Results | |
levelplot(sim1 ~ x + y | z, as.data.frame(res3D)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment