[R-sig-Geo] times and ID records for sp

Michael Sumner mdsumner at utas.edu.au
Wed Apr 19 02:45:29 CEST 2006


Hello, so far it's going well.  I have a class "SpatialPointsTOR" that 
extends SpatialPoints by adding two slots:

library(sp)
setClass("SpatialPointsTOR", representation("SpatialPoints", timeID = 
"matrix", TORlevels = "character"))

I suspect it would be better to create a completely separate class and 
so hide the expanding list of slots inside that ?
But so far I have print, plot, show, summary, "[" methods for the class 
that do what I want by indexing the id column
of timeID to TORlevels, and simply assuming the epoch = 
ISOdatetime(1970, 1, 1, 0, 0, 0, tz = "GMT") and adding that
to the time column.  (I'll have to think about cases for POSIXlt, and 
for Dates).

Thanks so much for sp!  This is already useful to me, and it will be 
nice to replace my clunky other classes with the
real power of sp. Once I've done a little more I'll package it up and 
provide some examples.

########################################################################################
########################################################################################

My new question involves a potential problem if proj4strings are passed 
in as "NA" rather than as.character(NA):

pts <- SpatialPoints(matrix(c(159, 143, -43, -42), ncol =2), 
CRS("+proj=longlat"))
is.projected(pts)
library(rgdal)
pts <- transform(pts, CRS("+proj=lcc +lon_0=160"))

So far so good, but is.projected seems to just grep for "longlat" and 
otherwise return TRUE.  Shouldn't this have some
validation of the CRS to avoid the following?
pts <- SpatialPoints(matrix(c(159, 143, -43, -42), ncol =2), "NA")   
is.projected(pts)  #TRUE

(I'm not sure how common this would be but I certainly made the error with
a constructor like this:
...
p4string <- "NA"
new("SpatialPointsTOR", SpatialPoints(crds, proj4string = 
CRS(p4string)), ...


Cheers, Mike.




More information about the R-sig-Geo mailing list