https://github.com/cran/spacetime
Tip revision: 6e48c7e9f90577efab0fa766ec303492f8733be8 authored by Edzer Pebesma on 26 August 2011, 13:09:00 UTC
version 0.5-3
version 0.5-3
Tip revision: 6e48c7e
basic.Rout.save
R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-pc-linux-gnu (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> options(digits=5)
> ###################################################
> ### chunk number 4:
> ###################################################
> library(spacetime)
Loading required package: sp
Loading required package: zoo
Loading required package: xts
> set.seed(13579) # to make outcome a bit predictable!
> sp = cbind(x = c(0,0,1), y = c(0,1,1))
> row.names(sp) = paste("point", 1:nrow(sp), sep="")
> sp = SpatialPoints(sp)
> 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), sep = "_")
> mydata = data.frame(values = signif(mydata,3), ID=IDs)
> stfdf = STFDF(sp, time, mydata)
>
>
> ###################################################
> ### chunk number 5:
> ###################################################
> as.data.frame(stfdf, row.names = IDs)
x y sp.ID time timedata values ID
ID_1 0 0 point1 2010-08-05 10:00:00 1 8.77 ID_1
ID_2 0 1 point2 2010-08-05 10:00:00 1 18.70 ID_2
ID_3 1 1 point3 2010-08-05 10:00:00 1 29.70 ID_3
ID_4 0 0 point1 2010-08-05 11:00:00 2 8.47 ID_4
ID_5 0 1 point2 2010-08-05 11:00:00 2 21.10 ID_5
ID_6 1 1 point3 2010-08-05 11:00:00 2 32.50 ID_6
ID_7 0 0 point1 2010-08-05 12:00:00 3 10.80 ID_7
ID_8 0 1 point2 2010-08-05 12:00:00 3 20.20 ID_8
ID_9 1 1 point3 2010-08-05 12:00:00 3 29.00 ID_9
ID_10 0 0 point1 2010-08-05 13:00:00 4 9.74 ID_10
ID_11 0 1 point2 2010-08-05 13:00:00 4 20.70 ID_11
ID_12 1 1 point3 2010-08-05 13:00:00 4 30.50 ID_12
> as(stfdf, "data.frame")[1:4,]
x y sp.ID time timedata values ID
1 0 0 point1 2010-08-05 10:00:00 1 8.77 ID_1
2 0 1 point2 2010-08-05 10:00:00 1 18.70 ID_2
3 1 1 point3 2010-08-05 10:00:00 1 29.70 ID_3
4 0 0 point1 2010-08-05 11:00:00 2 8.47 ID_4
>
> ###################################################
> ### chunk number 6:
> ###################################################
> unstack(stfdf)
point1 point2 point3
2010-08-05 10:00:00 8.77 18.7 29.7
2010-08-05 11:00:00 8.47 21.1 32.5
2010-08-05 12:00:00 10.80 20.2 29.0
2010-08-05 13:00:00 9.74 20.7 30.5
> t(unstack(stfdf))
2010-08-05 10:00:00 2010-08-05 11:00:00 2010-08-05 12:00:00
point1 8.77 8.47 10.8
point2 18.70 21.10 20.2
point3 29.70 32.50 29.0
2010-08-05 13:00:00
point1 9.74
point2 20.70
point3 30.50
> unstack(stfdf, which = 2)
point1 point2 point3
2010-08-05 10:00:00 ID_1 ID_2 ID_3
2010-08-05 11:00:00 ID_4 ID_5 ID_6
2010-08-05 12:00:00 ID_7 ID_8 ID_9
2010-08-05 13:00:00 ID_10 ID_11 ID_12
>
> ###################################################
> ### chunk number 7:
> ###################################################
> as(stfdf, "xts")
point1 point2 point3
2010-08-05 10:00:00 8.77 18.7 29.7
2010-08-05 11:00:00 8.47 21.1 32.5
2010-08-05 12:00:00 10.80 20.2 29.0
2010-08-05 13:00:00 9.74 20.7 30.5
>
> ###################################################
> ### chunk number 8:
> ###################################################
> stfdf[[1]]
[1] 8.77 18.70 29.70 8.47 21.10 32.50 10.80 20.20 29.00 9.74 20.70 30.50
> stfdf[["values"]]
[1] 8.77 18.70 29.70 8.47 21.10 32.50 10.80 20.20 29.00 9.74 20.70 30.50
> stfdf[["newVal"]] <- rnorm(12)
> stfdf$ID
[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
> stfdf$ID = paste("OldIDs", 1:12, sep="")
> stfdf$NewID = paste("NewIDs", 12:1, sep="")
> stfdf
An object of class "STFDF"
Slot "data":
values ID newVal NewID
1 8.77 OldIDs1 -0.766670 NewIDs12
2 18.70 OldIDs2 -0.437290 NewIDs11
3 29.70 OldIDs3 -0.471551 NewIDs10
4 8.47 OldIDs4 -0.561384 NewIDs9
5 21.10 OldIDs5 -1.215165 NewIDs8
6 32.50 OldIDs6 0.246818 NewIDs7
7 10.80 OldIDs7 -0.861698 NewIDs6
8 20.20 OldIDs8 0.659911 NewIDs5
9 29.00 OldIDs9 -0.036842 NewIDs4
10 9.74 OldIDs10 -0.952524 NewIDs3
11 20.70 OldIDs11 -1.699710 NewIDs2
12 30.50 OldIDs12 0.899851 NewIDs1
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
>
>
> ###################################################
> ### chunk number 9:
> ###################################################
> stfdf[,1] # SpatialPointsDataFrame:
coordinates values ID newVal NewID
1 (0, 0) 8.77 OldIDs1 -0.76667 NewIDs12
2 (0, 1) 18.70 OldIDs2 -0.43729 NewIDs11
3 (1, 1) 29.70 OldIDs3 -0.47155 NewIDs10
> stfdf[,,1]
An object of class "STFDF"
Slot "data":
values
1 8.77
2 18.70
3 29.70
4 8.47
5 21.10
6 32.50
7 10.80
8 20.20
9 29.00
10 9.74
11 20.70
12 30.50
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
> stfdf[1,,1] # xts
values
2010-08-05 10:00:00 8.77
2010-08-05 11:00:00 8.47
2010-08-05 12:00:00 10.80
2010-08-05 13:00:00 9.74
> stfdf[,,"ID"]
An object of class "STFDF"
Slot "data":
ID
1 OldIDs1
2 OldIDs2
3 OldIDs3
4 OldIDs4
5 OldIDs5
6 OldIDs6
7 OldIDs7
8 OldIDs8
9 OldIDs9
10 OldIDs10
11 OldIDs11
12 OldIDs12
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
> stfdf[1,,"values", drop=FALSE] # stays STFDF:
An object of class "STFDF"
Slot "data":
values
1 8.77
4 8.47
7 10.80
10 9.74
Slot "sp":
SpatialPoints:
x y
point1 0 0
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
> stfdf[,1, drop=FALSE] #stays STFDF
An object of class "STFDF"
Slot "data":
values ID newVal NewID
1 8.77 OldIDs1 -0.76667 NewIDs12
2 18.70 OldIDs2 -0.43729 NewIDs11
3 29.70 OldIDs3 -0.47155 NewIDs10
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
>
> ###################################################
> ### chunk number 10:
> ###################################################
> showClass("STSDF")
Class "STSDF" [package "spacetime"]
Slots:
Name: data index sp time
Class: data.frame matrix Spatial xts
Extends:
Class "STS", directly
Class "ST", by class "STS", distance 2
>
> ###################################################
> ### chunk number 11:
> ###################################################
> showClass("STIDF")
Class "STIDF" [package "spacetime"]
Slots:
Name: data sp time
Class: data.frame Spatial xts
Extends:
Class "STI", directly
Class "ST", by class "STI", distance 2
Known Subclasses: "STIDFtraj"
> sp = expand.grid(x = 1:3, y = 1:3)
> row.names(sp) = paste("point", 1:nrow(sp), sep="")
> sp = SpatialPoints(sp)
> time = xts(1:9, as.POSIXct("2010-08-05")+3600*(11:19))
> m = 1:9 * 10 # means for each of the 9 point locations
> mydata = rnorm(length(sp), mean=m)
> IDs = paste("ID",1:length(mydata))
> mydata = data.frame(values = signif(mydata,3),ID=IDs)
> stidf = STIDF(sp, time, mydata)
> stidf
An object of class "STIDF"
Slot "data":
values ID
1 10.7 ID 1
2 19.8 ID 2
3 29.2 ID 3
4 41.8 ID 4
5 50.2 ID 5
6 59.9 ID 6
7 70.9 ID 7
8 80.0 ID 8
9 90.2 ID 9
Slot "sp":
SpatialPoints:
x y
[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
Coordinate Reference System (CRS) arguments: NA
Slot "time":
[,1]
2010-08-05 11:00:00 1
2010-08-05 12:00:00 2
2010-08-05 13:00:00 3
2010-08-05 14:00:00 4
2010-08-05 15:00:00 5
2010-08-05 16:00:00 6
2010-08-05 17:00:00 7
2010-08-05 18:00:00 8
2010-08-05 19:00:00 9
>
>
> ###################################################
> ### chunk number 12:
> ###################################################
> stidf[1:2,]
An object of class "STIDF"
Slot "data":
values ID
1 10.7 ID 1
2 19.8 ID 2
Slot "sp":
SpatialPoints:
x y
[1,] 1 1
[2,] 2 1
Coordinate Reference System (CRS) arguments: NA
Slot "time":
[,1]
2010-08-05 11:00:00 1
2010-08-05 12:00:00 2
>
>
> ###################################################
> ### chunk number 13:
> ###################################################
> stfdf[,time[3]]
coordinates values ID newVal NewID
7 (0, 0) 10.8 OldIDs7 -0.861698 NewIDs6
8 (0, 1) 20.2 OldIDs8 0.659911 NewIDs5
9 (1, 1) 29.0 OldIDs9 -0.036842 NewIDs4
>
>
> ###################################################
> ### chunk number 14:
> ###################################################
> class(stfdf[,time[3],drop=FALSE])
[1] "STFDF"
attr(,"package")
[1] "spacetime"
>
> ###################################################
> ### chunk number 15:
> ###################################################
> stfdf[1, , "values"]
values
2010-08-05 10:00:00 8.77
2010-08-05 11:00:00 8.47
2010-08-05 12:00:00 10.80
2010-08-05 13:00:00 9.74
>
> ###################################################
> ### chunk number 16:
> ###################################################
> class(stfdf[1,drop=FALSE])
[1] "STFDF"
attr(,"package")
[1] "spacetime"
>
>
> ###################################################
> ### chunk number 17:
> ###################################################
> class(stfdf)
[1] "STFDF"
attr(,"package")
[1] "spacetime"
> class(as(stfdf, "STSDF"))
[1] "STSDF"
attr(,"package")
[1] "spacetime"
> class(as(as(stfdf, "STSDF"), "STIDF"))
[1] "STIDF"
attr(,"package")
[1] "spacetime"
> class(as(stfdf, "STIDF"))
[1] "STIDF"
attr(,"package")
[1] "spacetime"
>
>
> ###################################################
> ### chunk number 18:
> ###################################################
> x = as(stfdf, "STIDF")
> class(as(x, "STSDF"))
[1] "STSDF"
attr(,"package")
[1] "spacetime"
> class(as(as(x, "STSDF"), "STFDF"))
[1] "STFDF"
attr(,"package")
[1] "spacetime"
> class(as(x, "STFDF"))
[1] "STFDF"
attr(,"package")
[1] "spacetime"
> xx = as(x, "STFDF")
> identical(stfdf, xx)
[1] TRUE
>
> stsdf = as(stfdf, "STSDF")
> stsdf[[1]]
[1] 8.77 18.70 29.70 8.47 21.10 32.50 10.80 20.20 29.00 9.74 20.70 30.50
> stsdf[["values"]]
[1] 8.77 18.70 29.70 8.47 21.10 32.50 10.80 20.20 29.00 9.74 20.70 30.50
> stsdf[["newVal"]] <- rnorm(12)
> stsdf$ID
[1] "OldIDs1" "OldIDs2" "OldIDs3" "OldIDs4" "OldIDs5" "OldIDs6"
[7] "OldIDs7" "OldIDs8" "OldIDs9" "OldIDs10" "OldIDs11" "OldIDs12"
> stsdf$ID = paste("OldIDs", 1:12, sep="")
> stsdf$NewID = paste("NewIDs", 12:1, sep="")
> stsdf
An object of class "STSDF"
Slot "data":
values ID newVal NewID
1 8.77 OldIDs1 -1.24345 NewIDs12
2 18.70 OldIDs2 -1.47698 NewIDs11
3 29.70 OldIDs3 -0.84284 NewIDs10
4 8.47 OldIDs4 1.54992 NewIDs9
5 21.10 OldIDs5 1.04955 NewIDs8
6 32.50 OldIDs6 1.35744 NewIDs7
7 10.80 OldIDs7 1.33925 NewIDs6
8 20.20 OldIDs8 0.77757 NewIDs5
9 29.00 OldIDs9 0.39454 NewIDs4
10 9.74 OldIDs10 0.15138 NewIDs3
11 20.70 OldIDs11 -0.38780 NewIDs2
12 30.50 OldIDs12 0.46815 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
> stsdf[,1] # SpatialPointsDataFrame:
coordinates values ID newVal NewID
1 (0, 0) 8.77 OldIDs1 -1.24345 NewIDs12
2 (0, 1) 18.70 OldIDs2 -1.47698 NewIDs11
3 (1, 1) 29.70 OldIDs3 -0.84284 NewIDs10
> stsdf[,,1]
An object of class "STSDF"
Slot "data":
values
1 8.77
2 18.70
3 29.70
4 8.47
5 21.10
6 32.50
7 10.80
8 20.20
9 29.00
10 9.74
11 20.70
12 30.50
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
> stsdf[1,,1] # xts
values
2010-08-05 10:00:00 8.77
2010-08-05 11:00:00 8.47
2010-08-05 12:00:00 10.80
2010-08-05 13:00:00 9.74
> stsdf[,,"ID"]
An object of class "STSDF"
Slot "data":
ID
1 OldIDs1
2 OldIDs2
3 OldIDs3
4 OldIDs4
5 OldIDs5
6 OldIDs6
7 OldIDs7
8 OldIDs8
9 OldIDs9
10 OldIDs10
11 OldIDs11
12 OldIDs12
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
> stsdf[1,,"values", drop=FALSE] # stays STIDF:
An object of class "STSDF"
Slot "data":
values
1 8.77
4 8.47
7 10.80
10 9.74
Slot "index":
[,1] [,2]
[1,] 1 1
[2,] 1 2
[3,] 1 3
[4,] 1 4
Slot "sp":
SpatialPoints:
x y
point1 0 0
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
> stsdf[,1, drop=FALSE] #stays STIDF
An object of class "STSDF"
Slot "data":
values ID newVal NewID
1 8.77 OldIDs1 -1.24345 NewIDs12
2 18.70 OldIDs2 -1.47698 NewIDs11
3 29.70 OldIDs3 -0.84284 NewIDs10
Slot "index":
[,1] [,2]
[1,] 1 1
[2,] 2 1
[3,] 3 1
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
> as.data.frame(stsdf)
x y sp.ID time timedata values ID newVal NewID
1 0 0 point1 2010-08-05 10:00:00 1 8.77 OldIDs1 -1.24345 NewIDs12
2 0 1 point2 2010-08-05 10:00:00 1 18.70 OldIDs2 -1.47698 NewIDs11
3 1 1 point3 2010-08-05 10:00:00 1 29.70 OldIDs3 -0.84284 NewIDs10
4 0 0 point1 2010-08-05 11:00:00 2 8.47 OldIDs4 1.54992 NewIDs9
5 0 1 point2 2010-08-05 11:00:00 2 21.10 OldIDs5 1.04955 NewIDs8
6 1 1 point3 2010-08-05 11:00:00 2 32.50 OldIDs6 1.35744 NewIDs7
7 0 0 point1 2010-08-05 12:00:00 3 10.80 OldIDs7 1.33925 NewIDs6
8 0 1 point2 2010-08-05 12:00:00 3 20.20 OldIDs8 0.77757 NewIDs5
9 1 1 point3 2010-08-05 12:00:00 3 29.00 OldIDs9 0.39454 NewIDs4
10 0 0 point1 2010-08-05 13:00:00 4 9.74 OldIDs10 0.15138 NewIDs3
11 0 1 point2 2010-08-05 13:00:00 4 20.70 OldIDs11 -0.38780 NewIDs2
12 1 1 point3 2010-08-05 13:00:00 4 30.50 OldIDs12 0.46815 NewIDs1
> as(stsdf, "data.frame")
x y sp.ID time timedata values ID newVal NewID
1 0 0 point1 2010-08-05 10:00:00 1 8.77 OldIDs1 -1.24345 NewIDs12
2 0 1 point2 2010-08-05 10:00:00 1 18.70 OldIDs2 -1.47698 NewIDs11
3 1 1 point3 2010-08-05 10:00:00 1 29.70 OldIDs3 -0.84284 NewIDs10
4 0 0 point1 2010-08-05 11:00:00 2 8.47 OldIDs4 1.54992 NewIDs9
5 0 1 point2 2010-08-05 11:00:00 2 21.10 OldIDs5 1.04955 NewIDs8
6 1 1 point3 2010-08-05 11:00:00 2 32.50 OldIDs6 1.35744 NewIDs7
7 0 0 point1 2010-08-05 12:00:00 3 10.80 OldIDs7 1.33925 NewIDs6
8 0 1 point2 2010-08-05 12:00:00 3 20.20 OldIDs8 0.77757 NewIDs5
9 1 1 point3 2010-08-05 12:00:00 3 29.00 OldIDs9 0.39454 NewIDs4
10 0 0 point1 2010-08-05 13:00:00 4 9.74 OldIDs10 0.15138 NewIDs3
11 0 1 point2 2010-08-05 13:00:00 4 20.70 OldIDs11 -0.38780 NewIDs2
12 1 1 point3 2010-08-05 13:00:00 4 30.50 OldIDs12 0.46815 NewIDs1
>
> stidf = as(stfdf, "STIDF")
> stidf[[1]]
[1] 8.77 18.70 29.70 8.47 21.10 32.50 10.80 20.20 29.00 9.74 20.70 30.50
> stidf[["values"]]
[1] 8.77 18.70 29.70 8.47 21.10 32.50 10.80 20.20 29.00 9.74 20.70 30.50
> stidf[["newVal"]] <- rnorm(12)
> stidf$ID
[1] "OldIDs1" "OldIDs2" "OldIDs3" "OldIDs4" "OldIDs5" "OldIDs6"
[7] "OldIDs7" "OldIDs8" "OldIDs9" "OldIDs10" "OldIDs11" "OldIDs12"
> stidf$ID = paste("OldIDs", 1:12, sep="")
> stidf$NewID = paste("NewIDs", 12:1, sep="")
> stidf
An object of class "STIDF"
Slot "data":
values ID newVal NewID
1 8.77 OldIDs1 1.67415 NewIDs12
2 18.70 OldIDs2 -1.47819 NewIDs11
3 29.70 OldIDs3 -1.63290 NewIDs10
4 8.47 OldIDs4 -0.97491 NewIDs9
5 21.10 OldIDs5 -0.76499 NewIDs8
6 32.50 OldIDs6 0.10300 NewIDs7
7 10.80 OldIDs7 -1.06830 NewIDs6
8 20.20 OldIDs8 0.47947 NewIDs5
9 29.00 OldIDs9 1.17482 NewIDs4
10 9.74 OldIDs10 1.03354 NewIDs3
11 20.70 OldIDs11 0.82826 NewIDs2
12 30.50 OldIDs12 -0.75862 NewIDs1
Slot "sp":
SpatialPoints:
x y
point1 0 0
point2 0 1
point3 1 1
point1 0 0
point2 0 1
point3 1 1
point1 0 0
point2 0 1
point3 1 1
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 10:00:00 1
2010-08-05 10:00:00 1
2010-08-05 11:00:00 2
2010-08-05 11:00:00 2
2010-08-05 11:00:00 2
2010-08-05 12:00:00 3
2010-08-05 12:00:00 3
2010-08-05 12:00:00 3
2010-08-05 13:00:00 4
2010-08-05 13:00:00 4
2010-08-05 13:00:00 4
> stidf[,1] # SpatialPointsDataFrame:
An object of class "STIDF"
Slot "data":
values ID newVal NewID
1 8.77 OldIDs1 1.6741 NewIDs12
Slot "sp":
SpatialPoints:
x y
point1 0 0
Coordinate Reference System (CRS) arguments: NA
Slot "time":
[,1]
2010-08-05 10:00:00 1
> stidf[,,1]
An object of class "STIDF"
Slot "data":
values
1 8.77
2 18.70
3 29.70
4 8.47
5 21.10
6 32.50
7 10.80
8 20.20
9 29.00
10 9.74
11 20.70
12 30.50
Slot "sp":
SpatialPoints:
x y
point1 0 0
point2 0 1
point3 1 1
point1 0 0
point2 0 1
point3 1 1
point1 0 0
point2 0 1
point3 1 1
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 10:00:00 1
2010-08-05 10:00:00 1
2010-08-05 11:00:00 2
2010-08-05 11:00:00 2
2010-08-05 11:00:00 2
2010-08-05 12:00:00 3
2010-08-05 12:00:00 3
2010-08-05 12:00:00 3
2010-08-05 13:00:00 4
2010-08-05 13:00:00 4
2010-08-05 13:00:00 4
> stidf[1,,1] # xts
An object of class "STIDF"
Slot "data":
values
1 8.77
Slot "sp":
SpatialPoints:
x y
point1 0 0
Coordinate Reference System (CRS) arguments: NA
Slot "time":
[,1]
2010-08-05 10:00:00 1
> stidf[,,"ID"]
An object of class "STIDF"
Slot "data":
ID
1 OldIDs1
2 OldIDs2
3 OldIDs3
4 OldIDs4
5 OldIDs5
6 OldIDs6
7 OldIDs7
8 OldIDs8
9 OldIDs9
10 OldIDs10
11 OldIDs11
12 OldIDs12
Slot "sp":
SpatialPoints:
x y
point1 0 0
point2 0 1
point3 1 1
point1 0 0
point2 0 1
point3 1 1
point1 0 0
point2 0 1
point3 1 1
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 10:00:00 1
2010-08-05 10:00:00 1
2010-08-05 11:00:00 2
2010-08-05 11:00:00 2
2010-08-05 11:00:00 2
2010-08-05 12:00:00 3
2010-08-05 12:00:00 3
2010-08-05 12:00:00 3
2010-08-05 13:00:00 4
2010-08-05 13:00:00 4
2010-08-05 13:00:00 4
> stidf[1,,"values", drop=FALSE] # stays STIDF:
An object of class "STIDF"
Slot "data":
values
1 8.77
Slot "sp":
SpatialPoints:
x y
point1 0 0
Coordinate Reference System (CRS) arguments: NA
Slot "time":
[,1]
2010-08-05 10:00:00 1
> stidf[,1, drop=FALSE] #stays STIDF
An object of class "STIDF"
Slot "data":
values ID newVal NewID
1 8.77 OldIDs1 1.6741 NewIDs12
Slot "sp":
SpatialPoints:
x y
point1 0 0
Coordinate Reference System (CRS) arguments: NA
Slot "time":
[,1]
2010-08-05 10:00:00 1
> as.data.frame(stidf)
x y sp.ID time timedata values ID newVal NewID
1 0 0 point1 2010-08-05 10:00:00 1 8.77 OldIDs1 1.67415 NewIDs12
2 0 1 point2 2010-08-05 10:00:00 1 18.70 OldIDs2 -1.47819 NewIDs11
3 1 1 point3 2010-08-05 10:00:00 1 29.70 OldIDs3 -1.63290 NewIDs10
4 0 0 point1 2010-08-05 11:00:00 2 8.47 OldIDs4 -0.97491 NewIDs9
5 0 1 point2 2010-08-05 11:00:00 2 21.10 OldIDs5 -0.76499 NewIDs8
6 1 1 point3 2010-08-05 11:00:00 2 32.50 OldIDs6 0.10300 NewIDs7
7 0 0 point1 2010-08-05 12:00:00 3 10.80 OldIDs7 -1.06830 NewIDs6
8 0 1 point2 2010-08-05 12:00:00 3 20.20 OldIDs8 0.47947 NewIDs5
9 1 1 point3 2010-08-05 12:00:00 3 29.00 OldIDs9 1.17482 NewIDs4
10 0 0 point1 2010-08-05 13:00:00 4 9.74 OldIDs10 1.03354 NewIDs3
11 0 1 point2 2010-08-05 13:00:00 4 20.70 OldIDs11 0.82826 NewIDs2
12 1 1 point3 2010-08-05 13:00:00 4 30.50 OldIDs12 -0.75862 NewIDs1
> as(stidf, "data.frame")
x y sp.ID time timedata values ID newVal NewID
1 0 0 point1 2010-08-05 10:00:00 1 8.77 OldIDs1 1.67415 NewIDs12
2 0 1 point2 2010-08-05 10:00:00 1 18.70 OldIDs2 -1.47819 NewIDs11
3 1 1 point3 2010-08-05 10:00:00 1 29.70 OldIDs3 -1.63290 NewIDs10
4 0 0 point1 2010-08-05 11:00:00 2 8.47 OldIDs4 -0.97491 NewIDs9
5 0 1 point2 2010-08-05 11:00:00 2 21.10 OldIDs5 -0.76499 NewIDs8
6 1 1 point3 2010-08-05 11:00:00 2 32.50 OldIDs6 0.10300 NewIDs7
7 0 0 point1 2010-08-05 12:00:00 3 10.80 OldIDs7 -1.06830 NewIDs6
8 0 1 point2 2010-08-05 12:00:00 3 20.20 OldIDs8 0.47947 NewIDs5
9 1 1 point3 2010-08-05 12:00:00 3 29.00 OldIDs9 1.17482 NewIDs4
10 0 0 point1 2010-08-05 13:00:00 4 9.74 OldIDs10 1.03354 NewIDs3
11 0 1 point2 2010-08-05 13:00:00 4 20.70 OldIDs11 0.82826 NewIDs2
12 1 1 point3 2010-08-05 13:00:00 4 30.50 OldIDs12 -0.75862 NewIDs1
>