Problem with NetCDF file downloaded from an OpenDAP source

2 views (last 30 days)
Hello fellows I need to download a specific part of a NetCDF file from an OpenDAP source but i haven't been able to do it.
https://wci.earth2observe.eu/thredds/dodsC/ceh/wrr1/e2o_nerc_wrr1_glob30_day_Runoff_1979-2012.nc.html
I've used this link several times in google chrome, and in the last weeks I've downloaded the information in ascii format and then I've transformed it to a 3D-matrix. Although I would like to do it directly to my workspace.
The Data URL that is posted in the web page is this one
https://wci.earth2observe.eu/thredds/dodsC/ceh/wrr1/e2o_nerc_wrr1_glob30_day_Runoff_1979-2012.nc
and I have used these 2 commad lines without success
VARDATA=ncread('https://wci.earth2observe.eu/thredds/dodsC/ceh/wrr1/e2o_nerc_wrr1_glob30_day_Runoff_1979-2012.nc','Runoff',[188 208 730],[2 2 11323],[1 1 1]);
Error using internal.matlab.imagesci.nc/openToRead (line 1252)
Could not open
https://wci.earth2observe.eu/thredds/dodsC/ceh/wrr1/e2o_nerc_wrr1_glob30_day_Runoff_1979-2012.nc
for reading.
Error in internal.matlab.imagesci.nc (line 122)
this.openToRead();
Error in ncread (line 54)
ncObj = internal.matlab.imagesci.nc(ncFile);
and
VARDATA=ncread('https://wci.earth2observe.eu/thredds/dodsC/ceh/wrr1/e2o_nerc_wrr1_glob30_day_Runoff_1979-2012.nc.html','Runoff',[188 208 730],[2 2 11323],[1 1 1]);
Error using internal.matlab.imagesci.nc/openToRead (line 1252)
Could not open
https://wci.earth2observe.eu/thredds/dodsC/ceh/wrr1/e2o_nerc_wrr1_glob30_day_Runoff_1979-2012.nc.html
for reading.
Error in internal.matlab.imagesci.nc (line 122)
this.openToRead();
Error in ncread (line 54)
ncObj = internal.matlab.imagesci.nc(ncFile);
Could someone tell me how I can solve this? Thank you so much for the help

Answers (1)

Walter Roberson
Walter Roberson on 13 Oct 2015
I had a look at the code in my R2014a version. In my version at least, https sources are not supported. There are a few places where http: is tested for and https: is not considered. Even if you make direct calls into netcdflib to skip around those checks, then at least as of R2014a, netcdf itself will not permit the file to be opened.
I downloaded the latest netcdf C source and I do see that in there https is supported, so perhaps at some point MATLAB will catch up on the release.
You have a few options:
  • urlwrite() or equivalent the https: file to a local drive and read from there
  • load in a new netcdf dll library for your system and call into it
  • load in the netcdf library for Java and invoke that from MATLAB.
  • if you do not have the latest MATLAB (I do not) then you could upgrade and hope that they changed this.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!