[R-sig-Geo] spatio-temporal data
Tomislav Hengl
hengl at spatial-analyst.net
Sun Mar 17 12:25:31 CET 2013
That is a good question (I had the same problem when I started using the
spacetime package). It is all, of course, explained in the spacetime
package vignette (http://CRAN.R-project.org/package=spacetime), but one
more time:
To create an object of any class you can always use the command "new"
(http://stat.ethz.ch/R-manual/R-devel/library/methods/html/new.html).
For example, to create an object of type STIDF you would use:
new("STIDF", STI(sp, time, endTime), data = data)
But the creators of the spacetime package have also prepared methods
that would do that for you
(https://r-forge.r-project.org/scm/viewvc.php/pkg/R/STIDF-methods.R?view=markup&root=spacetime)
e.g.:
## load the data:
data(HRtemp08)
## format the time column:
HRtemp08$ctime <- as.POSIXct(HRtemp08$DATE, format="%Y-%m-%dT%H:%M:%SZ")
## create a STIDF object:
library(spacetime)
sp <- SpatialPoints(HRtemp08[,c("Lon","Lat")])
proj4string(sp) <- CRS("+proj=longlat +datum=WGS84")
HRtemp08.st <- STIDF(sp, time = HRtemp08$ctime, data =
HRtemp08[,c("NAME","TEMP")])
See also:
http://plotkml.r-forge.r-project.org/layer.STIDF.html
HTH,
T. Hengl
http://www.wewur.wur.nl/popups/vcard.aspx?id=HENGL001
On 16/03/2013 20:18, Saman Monfared wrote:
> Dear All,
> I want to construct a ST class data with spacetime package.
> Observations are cancer mortality rate in 15 fixed locations for
> sparse time in 7 years.
> I don't know how input my data as a locations and time. I have seen example
> data air and fires in this package but I can't understand how they constructed.
> for example can I input my data as a below then construct a st class?how?
>
> locations x y time
> point1 cord1 cord2 time1
> point1 cord1 cord2 time2
> . . . .
> . . . .
> Best.
>
More information about the R-sig-Geo
mailing list