library('geostatsp')
# exclude this line to use the RandomFields package
options(useRandomFields = FALSE)
model1 <- c(var=5, range=1,shape=0.5)
myraster = rast(nrows=20,ncols=30,extent = ext(0,6,0,4),
crs="+proj=utm +zone=17 +datum=NAD27 +units=m +no_defs")
set.seed(0)
simu <- RFsimulate(model1, x=myraster, n=3)
plot(simu[['sim2']])
xPoints = suppressWarnings(as.points(myraster))
# conditional simulation
firstSample = RFsimulate(
c(model1, nugget=1),
x=xPoints[seq(1,ncell(myraster), len=100), ],
n=3
)
secondSample = RFsimulate(
model = cbind(var=5:3, range=seq(0.05, 0.25, len=3), shape=seq(0.5, 1.5, len=3)),
err.model = 1,
x= myraster,
data=firstSample,n=4
)
plot(secondSample)
Run the code above in your browser using DataLab