RFsimulate | R Documentation |
This function simulates conditional and unconditional Gaussian random fields, calling the function in the RandomFields package of the same name.
## S4 method for signature 'ANY,SpatRaster'
RFsimulate(model, x, data=NULL,
err.model=NULL, n = 1, ...)
## S4 method for signature 'numeric,SpatRaster'
RFsimulate(model, x,data=NULL,
err.model=NULL, n = 1, ...)
## S4 method for signature 'numeric,SpatVector'
RFsimulate(model, x, data=NULL,
err.model=NULL, n = 1, ...)
## S4 method for signature 'RMmodel,SpatRaster'
RFsimulate(model, x, data=NULL,
err.model=NULL, n = 1, ...)
## S4 method for signature 'RMmodel,SpatVector'
RFsimulate(model, x, data=NULL,
err.model=NULL, n = 1, ...)
## S4 method for signature 'matrix,SpatRaster'
RFsimulate(model, x, data=NULL,
err.model=NULL, n = nrow(model), ...)
## S4 method for signature 'matrix,SpatVector'
RFsimulate(model, x, data=NULL,
err.model=NULL, n = nrow(model), ...)
## S4 method for signature 'data.frame,ANY'
RFsimulate(model, x, data=NULL,
err.model=NULL, n = nrow(model), ...)
modelRandomFields(param, includeNugget=FALSE)
model |
object of class \Sexpr[results=rd]{c( '\\\code{RMmodel}', '\\\command{\\\\link[RandomFields]{RMmodel}}' )[1+requireNamespace('RandomFields', quietly=TRUE)]}, a vector of named model parameters, or a matrix where each column is a model parameter |
x |
Object of type |
data |
For conditional simulation and random imputing only.
If |
err.model |
For conditional simulation and random imputing only. |
n |
number of realizations to generate. |
... |
for advanced use: further options and control parameters for the simulation that are passed to and processed by \Sexpr[results=rd]{c( '\\\code{RFoptions} in the \\\code{RandomFields} package', '\\\command{\\\\link[RandomFields]{RFoptions}}' )[1+requireNamespace('RandomFields', quietly=TRUE)]} |
param |
A vector of named parameters |
includeNugget |
If |
If model
is a matrix, a different set of parameters is used for each simulation. If
data
has the same number of columns as model
has rows,
a different column i
is used with parameters in row i
.
An object of the same class as x
.
Patrick E. Brown patrick.brown@utoronto.ca
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.