[R-sig-Geo] Time vs. Longitude (Hovmueller Diagram)

Roger Bivand Roger.Bivand at nhh.no
Wed Aug 17 09:13:16 CEST 2011


On Wed, 17 Aug 2011, Jianyun Wu wrote:

> Hi Michael,
> Thanks for the reply.
> The data file can be rechieved from the following link:
>
> ftp://ftp.wiley.com/public/sci_tech_med/spatio_temporal_data

>From Edzer Pebesma's notes in demo/CressieWikle.R in spacetime for the 
equator:

library(spacetime)
sst <- as.matrix(read.table("SST011970_032003.dat", header = FALSE))
sst.ll <- as.matrix(read.table("SSTlonlat.dat", header = FALSE))
sst.ll <- SpatialPoints(sst.ll)
proj4string(sst.ll) <- CRS("+proj=longlat +datum=WGS84")
gridded(sst.ll) <- TRUE
sst.y <- rep(1970:2003, each = 12, length.out = 399)
sst.m <- rep(1:12, length.out = 399)
sst.Date <- as.Date(paste(sst.y, sst.m, "01", sep="-"), "%Y-%m-%d")
sst.st <- STFDF(sst.ll, sst.Date, data.frame(sst = as.vector(sst)))
# note that the Spatial slot of this object does not need to be a
# regular grid, any Spatial* object will do; same for the time slot
# see the spacetime vignette
library(rgeos)
# choose latitude
lat <- 0
eq <- SpatialLines(list(Lines(list(Line(rbind(c(0, lat), c(360, lat)))), 
"equator")), CRS(proj4string(sst.st)))
# subset by overlaying latitude line across the grid using rgeos
stplot(sst.st[eq, "1996::2003", drop=F], mode = "xt", 
col.regions=bpy.colors(), cuts = 32, main="Figure 5.1", xlab="Longitude", 
ylab = "Time (Year)", scaleX=1)

Other examples for visualizing figures from Cressie & Wikle (2011) are 
included in the file.

Hope this helps,

Roger

>
> SST011970_032003.dat<ftp://ftp.wiley.com/public/sci_tech_med/spatio_temporal_data/SST011970_032003.dat>
> SSTdata_descrip.txt<ftp://ftp.wiley.com/public/sci_tech_med/spatio_temporal_data/SSTdata_descrip.txt>
> SSTlandmask.dat<ftp://ftp.wiley.com/public/sci_tech_med/spatio_temporal_data/SSTlandmask.dat>
> SSTlonlat.dat<ftp://ftp.wiley.com/public/sci_tech_med/spatio_temporal_data/SSTlonlat.dat>
> I will try the suggestion you provided, and wait for further comments.
>
> Thank you very much
>
> Fred
>
> On Wed, Aug 17, 2011 at 4:38 PM, Michael Sumner <mdsumner at gmail.com> wrote:
>
>> At a guess, for a given latitude you could do this where "x" is a
>> data.frame with columns Longitude, Latitude, Time1, ..., TimeN
>>
>> x1 <- x["Latitude" == -29, ]
>>
>> ## very simplistically
>>
>> ## drop Latitude, and order by Longitude (assuming Time columns are in
>> the right order)
>> x2 <- as.matrix(x1[order(x1$Longitude),  -2]
>>
>> image(x2)
>>
>> ## with a bit more work, but big assumptions
>>
>> lon <- sort(x1$Longitude)
>> tm <- as.numeric(colnames(x2)[-1])
>>
>> image(lon, tm, x2, main = "Latitude -29", xlab = "Longitude", ylab =
>> "Time")
>>
>>
>> There's a lot of guessing here for us, can you describe the file more
>> exactly or provide a link to at least one latitude's worth?
>>
>> The Spatial classes in sp provide much more structured support for
>> these grids, and the spacetime package even more for generalizing
>> further - but they rely on exactly regular grids, which it looks like
>> you have here.
>>
>> Cheers, Mike.
>>
>>
>> On Wed, Aug 17, 2011 at 1:45 PM, Jianyun Wu <jianyun.fred.wu at gmail.com>
>> wrote:
>>> Dear Experts,
>>>
>>> I am trying to plot the Hovmueller Diagram (example below), which is time
>>> vs. longitude in R.
>>>
>>>
>> http://www.esrl.noaa.gov/psd/cgi-bin/hovmoller/timeplot.pl?var=air&level=1000&mon1=1&mon2=1&dy1=1&dy2=31&yr1=2010&yr2=2011&datatype=operational&type=mean&fxdlon=no&postscript=no&lon1=&lon2=&lat1=&lat2=&cint=&lowr=&highr=&size=100&Submit=Create+Plot
>>>
>>> But I couldn't make it work at the moment. Could anyone please suggest me
>>> which package or function in R can plot such a graph?
>>>
>>> The data file on hand is like:
>>>
>>> Longtitude   Latitude   Time1.....................TimeN
>>>   124            -29
>>>   126            -29          .......................................
>>>   128            -29
>>>     ..             . .
>>>
>>> 2520 spatial locations corresponding to an 84 (longitude) by 30
>> (latitude)
>>> grid with 2 degree x 2 degree spacing.
>>>
>>> Thank and Regards
>>>
>>> Fred
>>>
>>>        [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>
>>
>>
>> --
>> Michael Sumner
>> Institute for Marine and Antarctic Studies, University of Tasmania
>> Hobart, Australia
>> e-mail: mdsumner at gmail.com
>>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list