edzer/spacetime

Major differences between STIDF and STFDF

Closed this issue · 2 comments

All:
I have read Dr. Pebesma's documentation regarding package spacetime, so please know I believe I have done my due diligence before posting. My main question is: I believe I have a dataset that satisfies the definition of STFDF, but cannot get it to run because of the following error:

Error in validityMethod(object) :
nrow(object@data) == length(object@sp) * nrow(object@time) is not TRUE

nrow for data = 123442
length of sp = 123442
length of time = 123442

Is this error literally saying: time * sp HAS to equal data?

This is a simple dataset of monthly unemployment statistics for Metropolitan Statistical areas around the US (data example below):

ID | STATE | DATE_III | TIME | DATETIME | UNEMPLOY_P
1001 | TX | 1/1/1990 | 12:00:00 | 1/1/1990 12:00 | 0.057
1363 | TX | 2/1/1990 | 12:00:00 | 2/1/1990 12:00 | 0.057
1725 | TX | 3/1/1990 | 12:00:00 | 3/1/1990 12:00 | 0.056
2087 | TX | 4/1/1990 | 12:00:00 | 4/1/1990 12:00 | 0.057
2449 | TX | 5/1/1990 | 12:00:00 | 5/1/1990 12:00 | 0.057
2811 | TX | 6/1/1990 | 12:00:00 | 6/1/1990 12:00 | 0.058

edzer commented

You don't specify what you did, so the only thing we can do is guessing. Did you try to read this dataset directly as STFDF? If yes, maybe try to read it as STIDF (I see a long table), and then try as(x, "STFDF").

Hello Dr. Pebesma,

I have figured it out. I was trying to shoot the DATE_III column directly into STFDF, when in reality all I needed to do was give it a start point (1990-01-01) for the POSIXct, and then because its a regular report, add a month (+2628000 seconds) for the endTIME interval offset. That worked.