[R-sig-Geo] spacetime stConstruct gives wrong dimensions for long table
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Wed Jun 24 11:50:05 CEST 2015
Dan, I'm moving this from r-help to r-sig-geo:
On 06/24/2015 11:29 AM, Bebber, Dan wrote:
> 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.
STIDF is essentially the long table form, it does not identify identical
space/time values.
Try:
dim(as(st, "STSDF"))
and
dim(as(st, "STFDF"))
after you figure out what these classes try to represent from the
package vignette / JSS paper.
>
> What am I doing wrong?
>
> Thanks,
> Dan
>
> Dr Dan Bebber
> Senior Research Fellow
> Biosciences
> University of Exeter
>
>
>
>
--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster,
Heisenbergstraße 2, 48149 Münster, Germany; +49 251 83 33081
Journal of Statistical Software: http://www.jstatsoft.org/
Computers & Geosciences: http://elsevier.com/locate/cageo/
Spatial Statistics Society http://www.spatialstatistics.info
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20150624/a620eb14/attachment.bin>
More information about the R-sig-Geo
mailing list