[R-sig-Geo] time slot in space-time sparse data frame (spacetime package)

Edzer Pebesma edzer.pebesma at uni-muenster.de
Thu Aug 25 23:19:45 CEST 2011


Hi Jochen,

On 07/25/2011 06:54 PM, Jochen Albrecht wrote:
> Hi:
> 1. I am working with the spacetime package and have successfully ingested a
> dataset into its *irregular* space-time data frame using coordinates for
> space, an xts object for time and auxiliary data for the attribute data.
> Next I tried to create a sparse space-time data frame (i.e. a grid) using
> the same pieces of data is successfully used before, plus the additional
> index. The STSDF function choked on the xts data that I tried to provide it
> with. The documentation on the sparse space-time data frame is, excuse the
> pun, sparse. There is no indication that the data structure to represent
> time is any different. The exact error message I get is:
> Error in checkSlotAssignment(object, name, value) :
>   c("assignment of an object of class \"POSIXct\" is not valid for slot
> \"time\" in an object of class \"ST\"; is(value, \"xts\") is not TRUE",
> "assignment of an object of class \"POSIXt\" is not valid for slot \"time\"
> in an object of class \"ST\"; is(value, \"xts\") is not TRUE")

this has been improved; updating the package should be sufficient.

> 
> 2.  Unrelated to this I have a more general question of understanding. After
> creating and plotting the irregular space-time data frame, I tried to coerce
> it into a full grid, alas without success. Section 7.2 of the vignette
> illustrates how to move from a full grid to a sparse or irregular one and
> then back again. Could it be that starting with an irregular one does not
> work? I kind of would understand that because mere coercion does not provide
> all the information needed - which is why I ended up trying to create the
> gridded data frames directly (my first question).

This is indeed a bug; it will "work" in the next version (now in svn).
The bug occurs when no duplicate locations or time points are present;
if this is the case, coercion to the sparse or full grid representations
may not give what you want, it does not interpolation / aggregation /
density or whatever analysis you have in mind.

The following will work, but as you see, object sizes explode for the
STFDF representation if the data ARE irregular.

> library(spacetime)
> n = 1000
> x = runif(n)
> y = runif(n)
> t = Sys.time()+ runif(n)
> x = STIDF(SpatialPoints(cbind(x,y)), t, data.frame(x = runif(n)))
> object.size(x)
43236 bytes
> object.size(as(x, "STSDF"))
51404 bytes
> object.size(as(x, "STFDF"))
8031244 bytes

You may want, as an initial analysis, use the method over (see the
over.pdf vignette) to overlay your data with a regular ST layout, and
e.g. count or average something from your irregular data in the new ST
"blocks" you define.

> 
> 3.  Finally, the data that I am trying to massage are buoy paths expressed
> as a good 22 million individual space-time points. I was thinking of using
> the irregular space-time data frame structure to create the 14,855 buoy
> paths (all buoys send their location information every six hours, some buoys
> survive for up to eight years) and then to interpolate ocean current
> surfaces similar to the Irish wind example in the spacetime vignette. The
> vignette example uses full grids; will I be able to do that with the sparse
> space-time data frames because the full matrix of the full grid would
> certainly go beyond the capabilities of 'R'?

That depends on your soft- and hardware setup and the interpolation you
have in mind.

There is also a vignette describing how to work on subsets of larger
tables in a PostGIS data base -- admittedly a proof of concept work, but
it might be provide a starting point in case capacity is your problem.

Your email has been unanswered for a month; if you're still trying this
path (or perhaps found another), I'm interested to hear your experience.

Best regards,

> 
> Cheers,
>      Jochen
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> 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