STSDF-class: Class "STSDF"

Description Usage Arguments Objects from the Class Slots Methods Author(s) References See Also Examples

Description

A class for spatio-temporal data with partial space-time grids; for n spatial locations and m times, an index table is kept for which nodes observations are available

Usage

1
2
3
4
5
6
7
8
  STS(sp, time, index, endTime = delta(time))
  STSDF(sp, time, data, index, endTime = delta(time))
  ## S4 method for signature 'STSDF'
x[i, j, ..., drop = is(x, "STSDF")]
  ## S4 method for signature 'STSDF,STFDF'
coerce(from, to, strict=TRUE)
  ## S4 method for signature 'STSDF,STIDF'
coerce(from, to, strict=TRUE)

Arguments

sp

object of class Spatial

time

object holding time information; see ST-class

data

data frame with rows corresponding to the observations (spatial index moving faster than temporal)

index

two-column matrix: rows corresponding to the nodes for which observations are available, first column giving spatial index, second column giving temporal index

endTime

vector of class POSIXct with end points of time intervals for the observations

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

Objects from the Class

Objects of this class carry sparse space/time grid data

Slots

sp:

Object of class "Spatial"

time:

Object holding time information; see ST-class for permitted types

index:

matrix of dimension n x 2, where n matches the number of rows in slot data

data:

Object of class data.frame, which holds the measured values

Methods

[

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

plot

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

plot

signature(x = "STSDF", y = "missing"): plots space-time layout, indicating records partially NA

Author(s)

Edzer Pebesma, [email protected]

References

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

See Also

delta

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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)
library(xts)
time = xts(1:4, 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
stsdf = as(stfdf, "STSDF")
stsdf[1:2,]
stsdf[,1:2]
stsdf[,,2]
stsdf[,,"values"]
stsdf[1,]
stsdf[,2]
# examples for [[, [[<-, $ and $<- 
stsdf[[1]]
stsdf[["values"]]
stsdf[["newVal"]] <- rnorm(12)
stsdf$ID
stsdf$ID = paste("OldIDs", 1:12, sep="")
stsdf$NewID = paste("NewIDs", 12:1, sep="")
stsdf
x = stsdf[stsdf,]
x = stsdf[stsdf[1:2,],]
all.equal(x, stsdf[1:2,])

Example output

Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

An object of class "STFDF"
Slot "data":
   values    ID
1   11.00  ID 1
2   20.30  ID 2
3   29.10  ID 3
4    9.85  ID 4
5   20.90  ID 5
6   29.10  ID 6
7    9.50  ID 7
8   20.90  ID 8
9   28.20  ID 9
10   9.87 ID 10
11  19.10 ID 11
12  28.10 ID 12

Slot "sp":
SpatialPoints:
       x y
point1 0 0
point2 0 1
point3 1 1
Coordinate Reference System (CRS) arguments: NA 

Slot "time":
                    [,1]
2010-08-05 10:00:00    1
2010-08-05 11:00:00    2
2010-08-05 12:00:00    3
2010-08-05 13:00:00    4

Slot "endTime":
[1] "2010-08-05 11:00:00 UTC" "2010-08-05 12:00:00 UTC"
[3] "2010-08-05 13:00:00 UTC" "2010-08-05 14:00:00 UTC"

An object of class "STSDF"
Slot "data":
   values    ID
1   11.00  ID 1
2   20.30  ID 2
4    9.85  ID 4
5   20.90  ID 5
7    9.50  ID 7
8   20.90  ID 8
10   9.87 ID 10
11  19.10 ID 11

Slot "index":
     [,1] [,2]
[1,]    1    1
[2,]    2    1
[3,]    1    2
[4,]    2    2
[5,]    1    3
[6,]    2    3
[7,]    1    4
[8,]    2    4

Slot "sp":
SpatialPoints:
       x y
point1 0 0
point2 0 1
Coordinate Reference System (CRS) arguments: NA 

Slot "time":
                    [,1]
2010-08-05 10:00:00    1
2010-08-05 11:00:00    2
2010-08-05 12:00:00    3
2010-08-05 13:00:00    4

Slot "endTime":
[1] "2010-08-05 11:00:00 UTC" "2010-08-05 12:00:00 UTC"
[3] "2010-08-05 13:00:00 UTC" "2010-08-05 14:00:00 UTC"

An object of class "STSDF"
Slot "data":
  values   ID
1  11.00 ID 1
2  20.30 ID 2
3  29.10 ID 3
4   9.85 ID 4
5  20.90 ID 5
6  29.10 ID 6

Slot "index":
     [,1] [,2]
[1,]    1    1
[2,]    2    1
[3,]    3    1
[4,]    1    2
[5,]    2    2
[6,]    3    2

Slot "sp":
SpatialPoints:
       x y
point1 0 0
point2 0 1
point3 1 1
Coordinate Reference System (CRS) arguments: NA 

Slot "time":
                    [,1]
2010-08-05 10:00:00    1
2010-08-05 11:00:00    2

Slot "endTime":
[1] "2010-08-05 11:00:00 UTC" "2010-08-05 12:00:00 UTC"

An object of class "STSDF"
Slot "data":
      ID
1   ID 1
2   ID 2
3   ID 3
4   ID 4
5   ID 5
6   ID 6
7   ID 7
8   ID 8
9   ID 9
10 ID 10
11 ID 11
12 ID 12

Slot "index":
      [,1] [,2]
 [1,]    1    1
 [2,]    2    1
 [3,]    3    1
 [4,]    1    2
 [5,]    2    2
 [6,]    3    2
 [7,]    1    3
 [8,]    2    3
 [9,]    3    3
[10,]    1    4
[11,]    2    4
[12,]    3    4

Slot "sp":
SpatialPoints:
       x y
point1 0 0
point2 0 1
point3 1 1
Coordinate Reference System (CRS) arguments: NA 

Slot "time":
                    [,1]
2010-08-05 10:00:00    1
2010-08-05 11:00:00    2
2010-08-05 12:00:00    3
2010-08-05 13:00:00    4

Slot "endTime":
[1] "2010-08-05 11:00:00 UTC" "2010-08-05 12:00:00 UTC"
[3] "2010-08-05 13:00:00 UTC" "2010-08-05 14:00:00 UTC"

An object of class "STSDF"
Slot "data":
   values
1   11.00
2   20.30
3   29.10
4    9.85
5   20.90
6   29.10
7    9.50
8   20.90
9   28.20
10   9.87
11  19.10
12  28.10

Slot "index":
      [,1] [,2]
 [1,]    1    1
 [2,]    2    1
 [3,]    3    1
 [4,]    1    2
 [5,]    2    2
 [6,]    3    2
 [7,]    1    3
 [8,]    2    3
 [9,]    3    3
[10,]    1    4
[11,]    2    4
[12,]    3    4

Slot "sp":
SpatialPoints:
       x y
point1 0 0
point2 0 1
point3 1 1
Coordinate Reference System (CRS) arguments: NA 

Slot "time":
                    [,1]
2010-08-05 10:00:00    1
2010-08-05 11:00:00    2
2010-08-05 12:00:00    3
2010-08-05 13:00:00    4

Slot "endTime":
[1] "2010-08-05 11:00:00 UTC" "2010-08-05 12:00:00 UTC"
[3] "2010-08-05 13:00:00 UTC" "2010-08-05 14:00:00 UTC"

                    values  ID      V1 
2010-08-05 10:00:00 "11.00" "ID 1"  "1"
2010-08-05 11:00:00 " 9.85" "ID 4"  "2"
2010-08-05 12:00:00 " 9.50" "ID 7"  "3"
2010-08-05 13:00:00 " 9.87" "ID 10" "4"
  coordinates values   ID
4      (0, 0)   9.85 ID 4
5      (0, 1)  20.90 ID 5
6      (1, 1)  29.10 ID 6
 [1] 11.00 20.30 29.10  9.85 20.90 29.10  9.50 20.90 28.20  9.87 19.10 28.10
 [1] 11.00 20.30 29.10  9.85 20.90 29.10  9.50 20.90 28.20  9.87 19.10 28.10
 [1] ID 1  ID 2  ID 3  ID 4  ID 5  ID 6  ID 7  ID 8  ID 9  ID 10 ID 11 ID 12
Levels: ID 1 ID 10 ID 11 ID 12 ID 2 ID 3 ID 4 ID 5 ID 6 ID 7 ID 8 ID 9
An object of class "STSDF"
Slot "data":
   values       ID      newVal    NewID
1   11.00  OldIDs1 -0.13334569 NewIDs12
2   20.30  OldIDs2  0.84315570 NewIDs11
3   29.10  OldIDs3 -0.48718344 NewIDs10
4    9.85  OldIDs4 -1.88155465  NewIDs9
5   20.90  OldIDs5 -0.24137861  NewIDs8
6   29.10  OldIDs6  0.89746049  NewIDs7
7    9.50  OldIDs7  1.52692193  NewIDs6
8   20.90  OldIDs8 -0.07534412  NewIDs5
9   28.20  OldIDs9  1.87779138  NewIDs4
10   9.87 OldIDs10 -0.15872780  NewIDs3
11  19.10 OldIDs11  1.61897157  NewIDs2
12  28.10 OldIDs12  0.69838646  NewIDs1

Slot "index":
      [,1] [,2]
 [1,]    1    1
 [2,]    2    1
 [3,]    3    1
 [4,]    1    2
 [5,]    2    2
 [6,]    3    2
 [7,]    1    3
 [8,]    2    3
 [9,]    3    3
[10,]    1    4
[11,]    2    4
[12,]    3    4

Slot "sp":
SpatialPoints:
       x y
point1 0 0
point2 0 1
point3 1 1
Coordinate Reference System (CRS) arguments: NA 

Slot "time":
                    [,1]
2010-08-05 10:00:00    1
2010-08-05 11:00:00    2
2010-08-05 12:00:00    3
2010-08-05 13:00:00    4

Slot "endTime":
[1] "2010-08-05 11:00:00 UTC" "2010-08-05 12:00:00 UTC"
[3] "2010-08-05 13:00:00 UTC" "2010-08-05 14:00:00 UTC"

[1] TRUE

spacetime documentation built on Sept. 25, 2017, 1:03 a.m.