Closed pascaloettli closed 1 year ago
It seems that RCurl is not recognising it as a valid URL. If I navigate to that URL I get
Error {
code = 400;
message = "Unrecognized request";
};
So something might be going on. It seems that RCurl is not as robust as one hopes to detect if something is a URL.
Adding .dds
at the end of the filename (i.e., https://psl.noaa.gov/thredds/dodsC/Datasets/ncep.reanalysis2/Monthlies/LTMs/gaussian_grid/air.2m.mon.ltm.nc.dds) gives:
Dataset {
Float32 level[level = 1];
Float32 lat[lat = 94];
Float32 lon[lon = 192];
Float64 time[time = 12];
Float64 climatology_bounds[time = 12][nbnds = 2];
Grid {
ARRAY:
Float32 air[time = 12][level = 1][lat = 94][lon = 192];
MAPS:
Float64 time[time = 12];
Float32 level[level = 1];
Float32 lat[lat = 94];
Float32 lon[lon = 192];
} air;
Grid {
ARRAY:
Int16 valid_yr_count[time = 12][level = 1][lat = 94][lon = 192];
MAPS:
Float64 time[time = 12];
Float32 level[level = 1];
Float32 lat[lat = 94];
Float32 lon[lon = 192];
} valid_yr_count;
} Datasets/ncep.reanalysis2/Monthlies/LTMs/gaussian_grid/air.2m.mon.ltm.nc;
And
f <- "https://psl.noaa.gov/thredds/dodsC/Datasets/ncep.reanalysis2/Monthlies/LTMs/gaussian_grid/air.2m.mon.ltm.nc.dds"
unname(file.access(f, 4) == 0 | RCurl::url.exists(f))
[1] TRUE
So maybe a two-step test is possible. First with the .nc
extension only. If FALSE
, adding .dds
extension and test again. If TRUE
, ncdf4::nc_open()
can read the .nc
file, as showed in the first post.
I think a better approach is to not try to do anything fancy and since I'm letting ncdf4
do all the reading, just let it tell me if it works or not. I'll just remove the checks and add some error trapping so it's clear that the error came from ReadNetCDF()
.
Hello,
The
ReadNetCDF
function is not able to open an OpenDAP dataset (for example here, the NCEP/DOE Reanalysis II)Using the {ncdf4} package:
We can get the metadata of the file. And this syntax works:
The problem seems related to the
checkURLFile
function: