Hi all,


I have the following error message when attempting to create a space-time class object (ST) from an existing long format table.



> TempData <- stConstruct(HourlyData, space="Station", time="Time", SpatialObj=MetStationPts)

Error: nrow(object@time) == length(object@sp) is not TRUE





"HourlyData" containins temperature measurements from 8 met stations (together with spatial ID and Time in a long format df)
The df is sorted by stations (8) then by time (1-hour intervals during months)

"MetStationPts" contains the met. station coordinates.


> str(HourlyData)
'data.frame':  35308 obs. of  13 variables:
$ Station      : chr  "17030" "17030" "17030" "17030"...
$ Time         : POSIXct, format: "2013-07-01 00:00:00" "2013-07-01 01:00:00" ...
$ TMean        : num  7.3 9.5 12.3 13.2 13.5 12.1 9.6 8.3 6.7 6.1




> str(MetStationPts)
Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
  ..@ data       :'data.frame':       8 obs. of  2 variables:
  .. ..$ ID  : chr [1:8] "17030" "23899" "23908" "25643" ...
  .. ..$ Name: Factor w/ 8 levels "Hamilton, Ruakura 2 Ews",..: 3 6 7 8 1 5 4 2
  ..@ coords.nrs : int [1:2] 3 4
  ..@ coords     : num [1:8, 1:2] 176 175 176 176 175 ...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:8] "17030" "23899" "23908" "25643" ...
  .. .. ..$ : chr [1:2] "X" "Y"
  ..@ bbox       : num [1:2, 1:2] 175.2 -39 176.9 -37.7
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:2] "X" "Y"
  .. .. ..$ : chr [1:2] "min" "max"
  ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
  .. .. ..@ projargs: chr "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"


Could anyone help me to interpret the error message?

Many thanks for your help.



Nicolas MEURISSE



________________________________


This e-mail and any attachments may contain information ...{{dropped:10}}

