[R] spacetime stConstruct gives wrong dimensions for long table
Bebber, Dan
D.Bebber at exeter.ac.uk
Wed Jun 24 11:29:10 CEST 2015
I have a large spatiotemporal database (131 spatial locations, 9 years of
daily weather data) in long table format which I would like to convert to
an ST object.
> head(tempmean)
site lat lon alt var year mth
day value date doy numdate
518941 27015260 6.02 -75.37 1680 AVERAGE DAILY TEMPERATURE VALUES 2006 1
1 16.9 2006-01-01 001 13149
518942 27015260 6.02 -75.37 1680 AVERAGE DAILY TEMPERATURE VALUES 2006 1
2 16.4 2006-01-02 002 13150
518943 27015260 6.02 -75.37 1680 AVERAGE DAILY TEMPERATURE VALUES 2006 1
3 16.9 2006-01-03 003 13151
518944 27015260 6.02 -75.37 1680 AVERAGE DAILY TEMPERATURE VALUES 2006 1
4 16.1 2006-01-04 004 13152
518945 27015260 6.02 -75.37 1680 AVERAGE DAILY TEMPERATURE VALUES 2006 1
5 16.6 2006-01-05 005 13153
518946 27015260 6.02 -75.37 1680 AVERAGE DAILY TEMPERATURE VALUES 2006 1
6 16.7 2006-01-06 006 13154
The data.frame is ‘ragged’, i.e. not all sites are represented by all
dates, and there are some NA values in the data.
I took a subset of the data (4 sites, 31 days in January 2006, for which
all site/date combinations are present) and tried
> st <- stConstruct(tempmean, 3:2, 10)
> summary(st)
Object of class STIDF
with Dimensions (s, t, attr): (124, 124, 9)
[[Spatial:]]
Object of class SpatialPoints
Coordinates:
min max
lon -76.45 -73.11
lat 2.11 7.07
Is projected: NA
proj4string : [NA]
Number of points: 124
[[Temporal:]]
Index timeIndex
Min. :2006-01-01 Min. : 1.00
1st Qu.:2006-01-08 1st Qu.: 31.75
Median :2006-01-16 Median : 62.50
Mean :2006-01-16 Mean : 62.50
3rd Qu.:2006-01-24 3rd Qu.: 93.25
Max. :2006-01-31 Max. :124.00
This is incorrect: There should be 4 spatial dimensions and 31 timepoints.
What am I doing wrong?
Thanks,
Dan
Dr Dan Bebber
Senior Research Fellow
Biosciences
University of Exeter
More information about the R-help
mailing list