Extracting sea surface temperatures from NOAA’s OISSTv2

Update, 2015-11-30It appears that NOAA has gone through and upgraded all of the OISST files to the newer version of the NetCDF file format. As a result, the functions outlined in this post don’t work any longer. Instead, see the updated functions in my newer post, http://lukemiller.org/index.php/2014/11/extracting-noaa-sea-surface-temperatures-with-ncdf4/. The concepts are the same as described here, but the newer functions use the ncdf4 package to access the newer NetCDF file format.

The OISSTv2 data are arranged in a 1° x 1° grid covering the entire world, and a weekly average has been calculated for each grid cell for each 7-day period starting Jan 1, 1990, in the file sst.wkmean.1990-present.nc. You will also want to grab the land-sea mask file lsmask.nc as well. The land-sea mask is necessary to remove the spurious temperature values that fall on the continents. In the script below I use the land-sea mask to simply convert all points over land into NA values in the output matrix.

This script makes use of two add-on packages available from the CRAN repositories. First, the ncdf package, written by David Pierce and maintained by Brian Ripley, is used to open the netCDF file and extract the desired data. The fields package, written by Reinhard Furrer, Douglas Nychka and Stephen Sain, provides the tools to plot the data with a color scale bar alongside the plot.