R - Plotting netcdf climate data

Viewed 19975

I have been trying plot the following gridded netcdf file: "air.1999.nc" found at the following website:

http://www.esrl.noaa.gov/psd/data/gridded/data.ncep.html

I have tried the code below based on answers I have found here and elsewhere, but no luck.

library(ncdf);
temp.nc <- open.ncdf("air.1999.nc");
temp <- get.var.ncdf(temp.nc,"air");

temp.nc$dim$lon$vals -> lon
temp.nc$dim$lat$vals -> lat

lat <- rev(lat)
temp <- temp[nrow(temp):1,]

temp[temp==-32767] <- NA
temp <- t(temp)

image(lon,lat,temp)
library(maptools)
data(wrld_simpl)
plot(wrld_simpl, add = TRUE)

This code was from modified from the one found here: The variable from a netcdf file comes out flipped

Does anyone have any ideas or experience with using these type of netcdf files? Thanks

1 Answers
Related