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

Michael Sumner mdsumner at gmail.com
Wed Aug 17 09:13:59 CEST 2011


Here's an update using the two files you need at a minimum:


## read the entire matrix file
x <- as.matrix(read.table("SST011970_032003.dat"))

## read the coordinates

lonlat <- read.table("SSTlonlat.dat")
names(lonlat) <- c("Longitude", "Latitude")

## choose just one lat
x1 <- x[lonlat$Latitude == -29, ]

ll <- lonlat[lonlat$Latitude == -29, ]

lon <- sort(ll$Longitude)
x2 <- x1[order(ll$Longitude), ]

tm <- 1:ncol(x1)

image(lon, tm, x2, main = "Latitude -29", xlab = "Longitude", ylab =
"Time", useRaster = TRUE, col = rainbow(28))

I will try to have a closer look later to get all the information
available. Please treat this with a grain of salt for now, and ignore
my previous guesses.

Cheers, Mike.

On Wed, Aug 17, 2011 at 4:53 PM, Jianyun Wu <jianyun.fred.wu at gmail.com> 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
>
> SST011970_032003.dat
> SSTdata_descrip.txt
> SSTlandmask.dat
> 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
>
>



-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsumner at gmail.com



More information about the R-sig-Geo mailing list