Learn R Programming

geostatsp (version 1.2.1)

RFsimulate: Simulation of Random Fields

Description

This function simulates conditional and unconditional Gaussian random fields: Here, only the simulation of Gaussian random fields is described. For other kind of random fields (binary, max-stable, etc.) or more sophisticated approaches see RFsimulateAdvanced.

Usage

## S3 method for class 'ANY,Raster':
RFsimulate(model, x,	data=NULL,
 err.model=NULL, n = 1, ...)
## S3 method for class 'numeric,SpatialGrid':
RFsimulate(model, x,data=NULL,
 err.model=NULL, n = 1, ...)
## S3 method for class 'numeric,SpatialPixels':
RFsimulate(model, x, data=NULL, 
err.model=NULL, n = 1, ...)
## S3 method for class 'numeric,SpatialPoints':
RFsimulate(model, x, data=NULL, 
 	err.model=NULL, n = 1, ...)
## S3 method for class 'numeric,GridTopology':
RFsimulate(model, x, data=NULL, 
 err.model=NULL, n = 1, ...)
## S3 method for class 'RMmodel,GridTopology':
RFsimulate(model, x, data=NULL, 
 err.model=NULL, n = 1, ...)
## S3 method for class 'RMmodel,SpatialPoints':
RFsimulate(model, x, data=NULL, 
 err.model=NULL, n = 1, ...)
## S3 method for class 'matrix,Raster':
RFsimulate(model, x, 	data=NULL, 
 err.model=NULL, n = nrow(model), ...)
## S3 method for class 'matrix,Spatial':
RFsimulate(model, x,	data=NULL, 
	err.model=NULL, n = nrow(model), ...)
## S3 method for class 'data.frame,ANY':
RFsimulate(model, x,	data=NULL, 
	err.model=NULL, n = nrow(model), ...)
modelRandomFields(param, includeNugget=FALSE)

Arguments

model
object of class RMmodel, a vector of named model parameters, or a matrix where each column is a model parameter
x
Object of type GridTopology or Raster or SpatialPoints or SpatialP
data
For conditional simulation and random imputing only. If data is missing, unconditional simulation is performed.Object of class SpatialPointsDataFrame; coordinates and
err.model
For conditional simulation and random imputing only. Usually err.model=RMnugget(var=var), or not given at all (error-free measurements).
n
number of realizations to generate.
...
for advanced use: further options and control parameters for the simulation that are passed to and processed by RFoptions
param
A vector of named parameters
includeNugget
If FALSE, the nugget parameter is ignored.

Value

  • An object of the same class as x, with the exception of x being a GridTopology where a Raster is returned.

Details

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.

See Also

RFsimulate, RFempiricalvariogram, RFfit, RFgetModelInfo, RFgui, RMmodel, RFoptions, RFsimulateAdvanced, RFsimulate.more.examples

Examples

Run this code
model <- c(var=5, range=1,shape=0.5)

if(requireNamespace('RandomFields', quietly=TRUE)) {
	RandomFields::plot(modelRandomFields(model))
}

myraster = raster(nrows=20,ncols=30,xmn=0,ymn=0,xmx=6,ymx=4, 
		crs="+init=epsg:2081")

set.seed(0) 

simu <- RFsimulate(model, x=myraster, n=3)

plot(simu[['sim2']])

# same again with SpatialPixels
myPoints = SpatialPixels(SpatialPoints(myraster))

# pass an argument 'cPrintlevel' to RandomFields
simuPoints <- RFsimulate(model, x=myPoints, n=3, cPrintlevel=8)
spplot(simuPoints, "sim1")

Run the code above in your browser using DataLab