Learn R Programming

spacetime (version 1.3-2)

STFDF-class: Class "STFDF"

Description

A class for spatio-temporal data with full space-time grid; for n spatial locations and m times, n x m observations are available

Usage

STF(sp, time, endTime = delta(time))
  STFDF(sp, time, data, endTime = delta(time))
  # S4 method for STFDF
[(x, i, j, ..., drop = is(x, "STFDF"))
  # S4 method for STFDF,xts
coerce(from, to, strict=TRUE)
  # S4 method for STFDF,Spatial
coerce(from, to)

Value

the as.data.frame coercion returns the full long table, with purely spatial attributes and purely time attributes replicated appropriately.

Objects from the Class

Objects of this class represent full space/time data with a full grid (or lattice) layout

Slots

sp:

spatial object; see ST-class

time:

temporal object; see ST-class

data:

Object of class data.frame, which holds the measured values; space index cycling first, time order preserved

Methods

[

signature(x = "STFDF"): selects spatial entities, temporal entities, and attributes

coerce

STFDF,xts

coerce

STFDF,Spatial

(from) coerces to (wide form) SpatialXxDataFrame, where SpatialXx is the spatial class of from@sp
plot

signature(x = "STF", y = "missing"): plots space-time layout

plot

signature(x = "STFDF", y = "missing"): plots space-time layout, indicating full missing valued records

% for spatial objects; does nothing but setting up a plotting region choosing % a suitable aspect if not given(see below), colouring the plot background using either a bg= argument or par("bg"), and possibly drawing axes. } % \item{summary}{\code{signature(object = "Spatial")}: summarize object}

Arguments

sp

object of class Spatial, having n elements

time

object holding time information, of length m; see ST for details

endTime

vector of class POSIXct, holding end points of time intervals; by default, time intervals equal the time step width, see delta

data

data frame with n*m rows corresponding to the observations (spatial index moving fastest)

x

an object of class STFDF

i

selection of spatial entities

j

selection of temporal entities (see syntax in package xts)

...

selection of attribute(s)

drop

if TRUE and a single spatial entity is selected, an object of class xts is returned; if TRUE and a single temporal entity is selected, and object of the appropriate Spatial class is returned; if FALSE, no coercion to reduced classes takes place

from

object of class STFDF

to

target class

strict

ignored

Author

Edzer Pebesma, edzer.pebesma@uni-muenster.de

References

https://www.jstatsoft.org/v51/i07/

Examples

Run this code
sp = cbind(x = c(0,0,1), y = c(0,1,1))
row.names(sp) = paste("point", 1:nrow(sp), sep="")
library(sp)
sp = SpatialPoints(sp)
time = as.POSIXct("2010-08-05")+3600*(10:13)
m = c(10,20,30) # means for each of the 3 point locations
mydata = rnorm(length(sp)*length(time),mean=rep(m, 4))
IDs = paste("ID",1:length(mydata))
mydata = data.frame(values = signif(mydata,3), ID=IDs)
stfdf = STFDF(sp, time, mydata)
stfdf
stfdf[1:2,]
stfdf[,1:2]
stfdf[,,2]
stfdf[,,"values"]
stfdf[1,]
stfdf[,2]
as(stfdf[,,1], "xts")
as(stfdf[,,2], "xts")
# examples for [[, [[<-, $ and $<- 
stfdf[[1]]
stfdf[["values"]]
stfdf[["newVal"]] <- rnorm(12)
stfdf$ID
stfdf$ID = paste("OldIDs", 1:12, sep="")
stfdf$NewID = paste("NewIDs", 12:1, sep="")
stfdf
x = stfdf[stfdf[1:2,],] 
all.equal(x, stfdf[1:2,]) 
all.equal(stfdf, stfdf[stfdf,]) # converts character to factor...

Run the code above in your browser using DataLab