R Under development (unstable) (2024-09-03 r87093 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 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. > # Sys.setenv(TZ="Europe/Berlin") > Sys.setenv(TZ="UTC") > > library(sp) > library(spacetime) > data(air) > rural = STFDF(stations, dates, data.frame(PM10 = as.vector(air))) > > rr <- rural[,"2005-06"] > > # conversion > rrSTFDF <- as(rr, "STFDF") > rrSTF <- as(rr, "STF") > > rrSTSDF <- as(rr, "STSDF") > rrSTS <- as(rr, "STS") > > rrSTIDF <- as(rr, "STIDF") > rrSTI <- as(rr, "STI") > > # selection types > # STF.. > rrSTFDF[1:2,3:4] # returns 4 values An object of class "STFDF" Slot "data": PM10 1 20.696 2 21.042 3 17.542 4 14.625 Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-03 2711 2005-06-04 2712 Slot "endTime": [1] "2005-06-04 UTC" "2005-06-05 UTC" > rrSTFDF[1:2,4:3] # returns 4 values An object of class "STFDF" Slot "data": PM10 1 20.696 2 21.042 3 17.542 4 14.625 Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-03 2711 2005-06-04 2712 Slot "endTime": [1] "2005-06-04 UTC" "2005-06-05 UTC" > rrSTFDF[cbind(2:1, 3:4)] # coerces matrix to vector, returns all time instances An object of class "STSDF" Slot "data": PM10 142 21.042 211 17.542 Slot "index": [,1] [,2] [1,] 1 1 [2,] 2 2 Slot "sp": SpatialPoints: coords.x1 coords.x2 DENI063 9.685030 53.52418 DESH001 9.585911 53.67057 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-03 2711 2005-06-04 2712 Slot "endTime": [1] "2005-06-04 UTC" "2005-06-05 UTC" > > rrSTF[2:1,] # returns 2 spatial and 2 temporal instances -> 4 instances An object of class "STF" Slot "sp": SpatialPoints: coords.x1 coords.x2 DENI063 9.685030 53.52418 DESH001 9.585911 53.67057 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-02 2710 2005-06-03 2711 2005-06-04 2712 2005-06-05 2713 2005-06-06 2714 2005-06-07 2715 2005-06-08 2716 2005-06-09 2717 2005-06-10 2718 2005-06-11 2719 2005-06-12 2720 2005-06-13 2721 2005-06-14 2722 2005-06-15 2723 2005-06-16 2724 2005-06-17 2725 2005-06-18 2726 2005-06-19 2727 2005-06-20 2728 2005-06-21 2729 2005-06-22 2730 2005-06-23 2731 2005-06-24 2732 2005-06-25 2733 2005-06-26 2734 2005-06-27 2735 2005-06-28 2736 2005-06-29 2737 2005-06-30 2738 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-03 UTC" "2005-06-04 UTC" "2005-06-05 UTC" [5] "2005-06-06 UTC" "2005-06-07 UTC" "2005-06-08 UTC" "2005-06-09 UTC" [9] "2005-06-10 UTC" "2005-06-11 UTC" "2005-06-12 UTC" "2005-06-13 UTC" [13] "2005-06-14 UTC" "2005-06-15 UTC" "2005-06-16 UTC" "2005-06-17 UTC" [17] "2005-06-18 UTC" "2005-06-19 UTC" "2005-06-20 UTC" "2005-06-21 UTC" [21] "2005-06-22 UTC" "2005-06-23 UTC" "2005-06-24 UTC" "2005-06-25 UTC" [25] "2005-06-26 UTC" "2005-06-27 UTC" "2005-06-28 UTC" "2005-06-29 UTC" [29] "2005-06-30 UTC" "2005-07-01 UTC" > rrSTF[cbind(4:1,1:4)] # returns 4 spatial and all temporal instances An object of class "STS" Slot "index": [,1] [,2] [1,] 1 1 [2,] 2 2 [3,] 3 3 [4,] 4 4 Slot "sp": SpatialPoints: coords.x1 coords.x2 DEBE056 13.647013 52.44775 DEUB038 9.791584 54.07312 DENI063 9.685030 53.52418 DESH001 9.585911 53.67057 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-02 2710 2005-06-03 2711 2005-06-04 2712 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-03 UTC" "2005-06-04 UTC" "2005-06-05 UTC" > > # STS.. > rrSTSDF[1:2,3:4] # returns 4 values An object of class "STSDF" Slot "data": PM10 141 20.696 142 21.042 211 17.542 212 14.625 Slot "index": [,1] [,2] [1,] 1 1 [2,] 2 1 [3,] 1 2 [4,] 2 2 Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-03 2711 2005-06-04 2712 Slot "endTime": [1] "2005-06-04 UTC" "2005-06-05 UTC" > rrSTSDF[cbind(1:2,3:4)] # returns 2 values for c(1,3) and c(2,4) An object of class "STSDF" Slot "data": PM10 141 20.696 212 14.625 Slot "index": [,1] [,2] [1,] 1 1 [2,] 2 2 Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-03 2711 2005-06-04 2712 Slot "endTime": [1] "2005-06-04 UTC" "2005-06-05 UTC" > rrSTSDF[cbind(2:1,3:4)] # returns 2 values for c(1,3) and c(2,4) An object of class "STSDF" Slot "data": PM10 142 21.042 211 17.542 Slot "index": [,1] [,2] [1,] 1 1 [2,] 2 2 Slot "sp": SpatialPoints: coords.x1 coords.x2 DENI063 9.685030 53.52418 DESH001 9.585911 53.67057 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-03 2711 2005-06-04 2712 Slot "endTime": [1] "2005-06-04 UTC" "2005-06-05 UTC" > > rrSTS[1:2,3:4] # returns 2 spatial and 2 temporal instances and an index with 4 instances An object of class "STS" Slot "index": [,1] [,2] [1,] 1 1 [2,] 2 1 [3,] 1 2 [4,] 2 2 Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-03 2711 2005-06-04 2712 Slot "endTime": [1] "2005-06-04 UTC" "2005-06-05 UTC" > rrSTS[cbind(1:2,3:4)] # returns 2 spatial and 2 temporal instances, but index with only 2 instances An object of class "STS" Slot "index": [,1] [,2] [1,] 1 1 [2,] 2 2 Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-03 2711 2005-06-04 2712 Slot "endTime": [1] "2005-06-04 UTC" "2005-06-05 UTC" > > # STI.. > rrSTIDF[1:2,1:2] # returns two first entries An object of class "STIDF" Slot "data": PM10 1 16.042 2 15.792 Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-01 2709 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-02 UTC" > rrSTIDF[1:2,] # returns two first entries An object of class "STIDF" Slot "data": PM10 1 16.042 2 15.792 Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-01 2709 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-02 UTC" > rrSTIDF[,1:2] # returns two first entries An object of class "STIDF" Slot "data": PM10 1 16.042 2 15.792 Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-01 2709 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-02 UTC" > rrSTIDF[cbind(1:2,1:2)] # returns two first entries An object of class "STIDF" Slot "data": PM10 1 16.042 2 15.792 Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-01 2709 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-02 UTC" > > rrSTI[1:2,1:2] # returns two first instances An object of class "STI" Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-01 2709 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-02 UTC" > rrSTI[1:2,] # returns two first instances An object of class "STI" Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-01 2709 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-02 UTC" > rrSTI[,1:2] # returns two first instances An object of class "STI" Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-01 2709 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-02 UTC" > rrSTI[cbind(1:2,1:2)] # returns two first instances An object of class "STI" Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-01 2709 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-02 UTC" > > # ordered selection > ################### > # is respected for STF.. > rrSTFDF[1:2,1:2]@data PM10 1 16.042 2 15.792 3 22.500 4 19.333 > rrSTFDF[1:2,2:1]@data PM10 1 16.042 2 15.792 3 22.500 4 19.333 > rrSTFDF[2:1,1:2]@data PM10 1 15.792 2 16.042 3 19.333 4 22.500 > > # and STS > rrSTSDF[1:2,1:2]@data PM10 1 16.042 2 15.792 71 22.500 72 19.333 > rrSTSDF[1:2,2:1]@data PM10 1 16.042 2 15.792 71 22.500 72 19.333 > rrSTSDF[2:1,1:2]@data PM10 2 15.792 1 16.042 72 19.333 71 22.500 > > # and for STI in one time slice > rrSTIDF[1:2,1:2]@data PM10 1 16.042 2 15.792 > # rrSTIDF[2:1,2:1]@data > > # > rrSTIDF[c(1,2),c(1,2)]@data PM10 1 16.042 2 15.792 > # rrSTIDF[c(2,1),c(1,2)]@data > rrSTIDF[c(1,200),c(1,200)]@data PM10 1 16.042 305 6.458 > # rrSTIDF[c(200,1),c(1,200)]@data > > # STx > rrSTF[1:2,1:2]@sp SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs > rrSTF[2:1,1:2]@sp SpatialPoints: coords.x1 coords.x2 DENI063 9.685030 53.52418 DESH001 9.585911 53.67057 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs > > rrSTS[1:2,1:2] An object of class "STS" Slot "index": [,1] [,2] [1,] 1 1 [2,] 2 1 [3,] 1 2 [4,] 2 2 Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-02 2710 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-03 UTC" > rrSTS[2:1,1:2] An object of class "STS" Slot "index": [,1] [,2] [1,] 1 1 [2,] 2 1 [3,] 1 2 [4,] 2 2 Slot "sp": SpatialPoints: coords.x1 coords.x2 DENI063 9.685030 53.52418 DESH001 9.585911 53.67057 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-02 2710 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-03 UTC" > rrSTS[2:1,2:1] An object of class "STS" Slot "index": [,1] [,2] [1,] 1 1 [2,] 2 1 [3,] 1 2 [4,] 2 2 Slot "sp": SpatialPoints: coords.x1 coords.x2 DENI063 9.685030 53.52418 DESH001 9.585911 53.67057 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-02 2710 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-03 UTC" > > rrSTS[1:2,1:2]@sp SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs > rrSTS[2:1,2:1]@sp SpatialPoints: coords.x1 coords.x2 DENI063 9.685030 53.52418 DESH001 9.585911 53.67057 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs > > # multiple selection > #################### > # returns multiple results for STF.. > rrSTF[rep(2,3), 1:2] An object of class "STF" Slot "sp": SpatialPoints: coords.x1 coords.x2 DENI063 9.68503 53.52418 DENI063 9.68503 53.52418 DENI063 9.68503 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-02 2710 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-03 UTC" > rrSTFDF[rep(2,3), 1:2] An object of class "STFDF" Slot "data": PM10 1 15.792 2 15.792 3 15.792 4 19.333 5 19.333 6 19.333 Slot "sp": SpatialPoints: coords.x1 coords.x2 DENI063 9.68503 53.52418 DENI063 9.68503 53.52418 DENI063 9.68503 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-02 2710 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-03 UTC" > rrSTF[rep(2,3), rep(2,2)] An object of class "STF" Slot "sp": SpatialPoints: coords.x1 coords.x2 DENI063 9.68503 53.52418 DENI063 9.68503 53.52418 DENI063 9.68503 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-02 2710 2005-06-02 2710 Slot "endTime": [1] "2005-06-03 UTC" "2005-06-03 UTC" > rrSTFDF[rep(2,3), rep(2,2)] An object of class "STFDF" Slot "data": PM10 1 19.333 2 19.333 3 19.333 4 19.333 5 19.333 6 19.333 Slot "sp": SpatialPoints: coords.x1 coords.x2 DENI063 9.68503 53.52418 DENI063 9.68503 53.52418 DENI063 9.68503 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-02 2710 2005-06-02 2710 Slot "endTime": [1] "2005-06-03 UTC" "2005-06-03 UTC" > > # returns multiple results for STS.. > rrSTS[rep(2,3),1:2] An object of class "STS" Slot "index": [,1] [,2] [1,] 1 1 [2,] 1 1 [3,] 1 1 [4,] 1 2 [5,] 1 2 [6,] 1 2 Slot "sp": SpatialPoints: coords.x1 coords.x2 DENI063 9.68503 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-02 2710 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-03 UTC" > rrSTSDF[rep(2,3),1:2]@data PM10 2 15.792 2.1 15.792 2.2 15.792 72 19.333 72.1 19.333 72.2 19.333 > rrSTS[rep(2,3), rep(2,2)] An object of class "STS" Slot "index": [,1] [,2] [1,] 1 1 [2,] 1 1 [3,] 1 1 [4,] 1 1 [5,] 1 1 [6,] 1 1 Slot "sp": SpatialPoints: coords.x1 coords.x2 DENI063 9.68503 53.52418 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-02 2710 Slot "endTime": [1] "2005-06-03 UTC" > rrSTSDF[rep(2,3), rep(2,2)]@data PM10 72 19.333 72.1 19.333 72.2 19.333 72.3 19.333 72.4 19.333 72.5 19.333 > > # returns unique results for STI.. > rrSTI[rep(3,3),rep(3,3)] An object of class "STI" Slot "sp": SpatialPoints: coords.x1 coords.x2 DEUB038 9.791584 54.07312 DEUB038 9.791584 54.07312 DEUB038 9.791584 54.07312 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-01 2709 2005-06-01 2709 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-02 UTC" "2005-06-02 UTC" > rrSTI[cbind(5:1,1:5),] An object of class "STI" Slot "sp": SpatialPoints: coords.x1 coords.x2 DEUB038 9.791584 54.07312 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 Slot "endTime": [1] "2005-06-02 UTC" > > rrSTIDF[rep(3,3),rep(3,3)] An object of class "STIDF" Slot "data": PM10 3 17.292 3.1 17.292 3.2 17.292 Slot "sp": SpatialPoints: coords.x1 coords.x2 DEUB038 9.791584 54.07312 DEUB038 9.791584 54.07312 DEUB038 9.791584 54.07312 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-01 2709 2005-06-01 2709 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-02 UTC" "2005-06-02 UTC" > rrSTIDF[cbind(5:1,1:5),] An object of class "STIDF" Slot "data": PM10 3 17.292 Slot "sp": SpatialPoints: coords.x1 coords.x2 DEUB038 9.791584 54.07312 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 Slot "endTime": [1] "2005-06-02 UTC" > rrSTIDF[cbind(1:5,1:5),] An object of class "STIDF" Slot "data": PM10 1 16.042 2 15.792 3 17.292 4 15.750 6 12.375 Slot "sp": SpatialPoints: coords.x1 coords.x2 DESH001 9.585911 53.67057 DENI063 9.685030 53.52418 DEUB038 9.791584 54.07312 DEBE056 13.647013 52.44775 DEBE032 13.225856 52.47309 Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs Slot "time": timeIndex 2005-06-01 2709 2005-06-01 2709 2005-06-01 2709 2005-06-01 2709 2005-06-01 2709 Slot "endTime": [1] "2005-06-02 UTC" "2005-06-02 UTC" "2005-06-02 UTC" "2005-06-02 UTC" [5] "2005-06-02 UTC" > > proc.time() user system elapsed 0.73 0.14 0.85