[R-sig-Geo] STFDF with n variables

piero campa piero.campa at gmail.com
Sun Dec 16 18:32:12 CET 2012


Dear list,
I am going to build a spacetime::STFDF object where the "n" spatial
locations hold "h" different values (different fields) over the "m" times.

Along the documentation (spacetime vignette, ?stConstruct, ?STFDF, ?reshape)
I only found examples with layout of {n·m·1} observations, and not {n·m·h}
as in my case.
[I might as well have missed such examples, so please forgive me in that
case]

I am writing here to have a confirmation that I am doing things correctly.
This is a toy-example of my workflow (letting out CRS or ending-times
details):

-----------------------------------
library(gstat)
library(spacetime)
data(meuse)
# subset
meuse <- meuse[c("cadmium", "copper", "x", "y")][1:10,]
coordinates(meuse) <- ~x+y
#
ds <- slot(meuse, "data")
meuse <- as(meuse, "SpatialPoints")
# append hypothetical values to match cardinality of data required
ds <- rbind(ds, ds+1)
# Assign dates
dts <- as.Date(c(1:2))
ds <- cbind(ds, time=sort(rep(dts,10)), id=1:nrow(ds))
# Rename field variables to avoid conflict
#names(ds) <- c("cadmiums", "coppers", "time", "id")
# Build the spacetime object: n=10, m=2, h=2
stMeuse = STFDF(meuse, dts, ds) 
str(stMeuse)
-----------------------------------

Thanks for any comment.
Piero







--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/STFDF-with-n-variables-tp7581966.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list