rnetcdfopendap

Loading OPeNDAP served netcdf file using ncdf4 in R under Windows


I have a script that downloads NetCDF data from an OPeNDAP server using the package ncdf4. The script works on my Mac laptop but fails on my Windows 7 desktop. On both machines, I am using the latest available version of R and ncdf4 (on Windows, it's R3.2.2 with ncdf4_1_9 installed from the latest available zip file; on the Mac, it is ncdf4_1.13 installed from source).

It works fine for opening locally stored NetCDF files, but when I try to access a NetCDF file from an OPeNDAP server (on Windows only), I get the error

Error in R_nc4_open: Invalid argument

I seem to be getting this error regardless of which opendap-served netcdf file I try to open. The one I actually need to access is currently not publicly available (served only internally), but I get the same message, for instance, when I try:

nc <- nc_open("http://measures.gsfc.nasa.gov/opendap/test/GOZ-Merged-MLP_H2O_ev1-01_1992.nc4")

or:

nc_open("http://www.esrl.noaa.gov/psd/thredds/dodsC/Datasets/ncep.marine/cldc.mean.nc")

Any tips? Escaping the slashes in the URL doesn't work. I'm hoping I won't need to install ncdf4 from source under Windows.


Solution

  • There’s now a version of the ncdf4 library on github that correctly handles OPeNDAP-served files:

    devtools::install_github(‘mdsumner/ncdf4’)