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!