[R-sig-Geo] STFDF with n variables
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Sun Dec 16 19:19:50 CET 2012
On 12/16/2012 06:32 PM, piero campa wrote:
> 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
Yes, that works:
> class(stMeuse)
[1] "STFDF"
attr(,"package")
[1] "spacetime"
> dim(stMeuse)
space time variables
10 2 4
stConstruct would need extension to be help here, it tries to build
STFDF objects from time- or space-wide tables -- with multiple
attributes, the organization of such tables is not unambiguous.
(also note that with the CRAN version of spacetime, you'd need to load
package zoo first in order to run your script)
> --
> 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.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics e.pebesma at wwu.de
More information about the R-sig-Geo
mailing list