[R-sig-Geo] Extend spacetime ST

chris english englishchristophera at gmail.com
Sat Jun 6 07:58:54 CEST 2015


Hi,

I am attempting to extent spacetime ST to include an ID class for a
spacetime watch circle object.  I am doing this in order to be able to
relatively easily test that I have unique ID(s) across several similar
objects for plotting purposes.

I can build my watch circle:

> setClass("watch_circ",
+ slots = c(sp = "Spatial", time = "xts", ID = "character",
+ endTime = "POSIXct"),
+ validity = function(object) {
+ stopifnot(length(object at sp) >= 1)
+ stopifnot(nrow(object at time) >= 1)
+ stopifnot(is.char(object at ID))
+ stopifnot(nrow(object at time) == length(object at endTime))
+ # do the tzones if not set, if set
+ tz1 = attr(object at time, "tzone")
+ tz2 = attr(object at emdTime, "tzone")
+ tz1.set = (!is.null(tz1) && !nchar(tz1)==0)
+ tz2.set = (!is.null(tz2) && !nchar(tz2)==0)
+ stopifnot(tz1 == tz2)
+ if (tz1.set)
+ stopifnot(tz1 == tz2)
+ if (any(names(object at time) %in% names(object at sp)))
+ stop("name conflict: attribute names in sp and time slot must differ")
+ return(TRUE)
+ }
+ )
> getClassDef('watch_circ')
Class "watch_circ" [in ".GlobalEnv"]

Slots:

Name:         sp      time        ID   endTime
Class:   Spatial       xts character   POSIXct

But not extend ST.

> setClass("watch_circ_1", representation = "ST")
> getClassDef('watch_circ_1')
Class "watch_circ_1" [in ".GlobalEnv"]

Slots:

Name:       sp    time endTime
Class: Spatial     xts POSIXct

Extends: "ST"
> ?what am I doing wrong here?

This is probably due to my shallow understanding of the difference between
slots and representation, and possibly this whole operation is unnecessary
if plot checks sp for unique ID(s) among objects.

Thanks in advance,

Cheers,
Chris

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list