Learn R Programming

RandomFields (version 3.1.12)

RFspatialGridDataFrame-class: Class "RFspatialGridDataFrame"

Description

Class for spatial attributes that have spatial or spatio-temporal locations (at least of dimension 2) on a (full) regular grid. Direct extension of class SpatialGridDataFrame from the sp-package. See sp2RF for an explicite transformation.

Usage

## S3 method for class 'RFspatialGridDataFrame':
RFspDataFrame2conventional(obj, data.frame=FALSE)

Arguments

obj
an RFspatialGridDataFrame object
data.frame
logical. If TRUE a data.frame is returned.

Creating Objects

Objects can be created by using the functions RFspatialGridDataFrame or conventional2RFspDataFrame or by calls of the form as(x, "RFspatialGridDataFrame"), where x is of class RFspatialGridDataFrame.

Extends

Class "SpatialGridDataFrame", directly. Class "SpatialGrid", by class "SpatialGridDataFrame". Class "Spatial", by class "SpatialGrid".

Details

Note that in the data-slot, each colums is ordered according to the ordering of coordinates(grid), the first dimension runs fastest and for all BUT the second dimension, coordinate values are in ascending order. In the second dimension, coordinate values run from high to low. Hence, when converting to conventional formats using RFspDataFrame2conventional or RFspDataFrame2dataArray, the data array is re-ordered such that all dimensions are in ascending order. as.matrix does not perform re-ordering.

Methods summary, dimensions and isGridded are defined for the parent-class RFsp.

See Also

RFspatialPointsDataFrame-class, which is for point locations that are not on a grid, RFgridDataFrame-class which is for one-dimensional locations, RFsp, sp2RF

Examples

Run this code
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set
##                   RFoptions(seed=NA) to make them all random again

n <- 3

x <- GridTopology(cellcentre.offset=c(0, 0),
 cellsize=c(1, 0.2),
 cells.dim=c(10, 30))
f <- RFsimulate(model=RMexp(), x=x, n=n)

str(f)
str(RFspDataFrame2conventional(f))
str(RFspDataFrame2dataArray(f))
coordinates(f)[1:25,]
str(f[2]) ## selects second column of data-slot
all.equal(f, cbind(f,f)[1:3]) ## TRUE
str(as(f, "RFspatialPointsDataFrame"))

plot(f, nmax=2)

steps <- c(10, 1, 10, 10)
if(!interactive()){warning("modified <steps>"); steps<-c(2,1,2,2)}x2 <- rbind(c(0, 0, 0, 0),
 c(1, 0.2, 2, 5),
 steps)
scale <- 10
if(!interactive()){warning("modified <scale>");scale<-0.1}f2 <- RFsimulate(model=RMwhittle(nu=1.2, scale=scale), x=x2, n=n,
                 grid = TRUE)
plot(f2, MARGIN=c(3,4), MARGIN.slices=1, n.slices=6, nmax=2)

f.sp <- RFsimulate(model=RMexp(), x=x, n=n, seed=0)
f.old <- RFsimulate(model=RMexp(), x=x, n=n, spConform=FALSE, seed=0)
all.equal(RFspDataFrame2conventional(f.sp)$data, f.old) ## TRUE
FinalizeExample()

Run the code above in your browser using DataLab