0
votes

I am relatively new to R so i apologize if I have trouble expressing what I'm attempting to do. I have a 'spatial' panel dataset in long form and a shapefile. The long form table is a data.frame and it includes a column of dates (that have been converted to dates using 'as.date') and an ID column that is the same as that in the shapefile used to identify the different polygons (thus my long form dataset has no long lat values just an ID field that corresponds to the polygon features in the shapefile). I want to construct a spatiotemporal object of class ST out of these two objects (the shapefile and the long form dataset). To do this I have tried using stcontruct() and STFDF() but with absolutely not luck. stcontruct() gives me this error:

stConstruct(x, x$ID, x$date, SpatialObj = pol, TimeObj = NULL, interval=FALSE) Error in stConstruct(x, x$ID, x$date, SpatialObj = pol, TimeObj = NULL, : unknown parameter combination

and STFDF() gives me this error:

STFDF(shapefile, x$date, x) Error: nrow(object@data) == length(object@sp) * nrow(object@time) is not TRUE

I've been stuck on this for days reading everything I can about the spacetime package in forums, etc. but to no avail. Any help is greatly appreciated.

thanks!

1
I was facing same errors. But for STFDF () error, upon verify the values of nrow(object@data), length(object@sp) and nrow(object@time) I was able to identify the issue. The problem in my case was that data was in Time-wide format with a separate row for each spatial point. I converted the structure of data by creating a single dimensional vector by appending data for each spatial point in single column. This solution was helpful. - akzhere

1 Answers

0
votes

About STFDF error

From:

http://r-sig-geo.2731867.n2.nabble.com/Error-with-STFDF-td7584461.html

"If you don't have every time value at every spatial point, then you can't have an STFDF object, as by definition STFDF is a full space by time grid.

The equation in the error is part of the definition/requirement for an STFDF object.

SDIDF objects don't have that requirement of all times at all locations..."