[R-sig-Geo] POSIX* objects and writeOGR()

Agustin Lobo alobolistas at gmail.com
Wed Dec 30 21:15:40 CET 2009

This might be a bit off-topic.
I have to export as shape an Sp.Poly.DF in which
one of the variables records date and time as POSIXtc. As
writeOGR() complains about the POSIXct variable, I'm
trying to convert to POSIXlt, which I think that will be
accepted (another alternative would be coverting to an
string char, but prefer to keep the SPDF object with
a correct class definition for that variable).
Let's call patata the table of the SPDF.

 > class(patata$Tima)
[1] "POSIXt"  "POSIXct"

 > patata$Tima[1]
[1] "2009-09-26 09:57:24 CEST"

 > as.POSIXlt(patata$Tima[1])
[1] "2009-09-26 09:57:24 CEST"

 > class(as.POSIXlt(patata$Tima[1]))
[1] "POSIXt"  "POSIXlt"

So I was happy, but:

 > patata$Tima <- as.POSIXlt(patata$Tima)
Error in `$<-.data.frame`(`*tmp*`, "Tima", value = list(sec = c(24, 33,  :
   replacement has 9 rows, data has 44
Calls: $<- -> $<-.data.frame

Is there any way I can put the POSIXlt object in the table (patata) of the SPDF 



More information about the R-sig-Geo mailing list