Error reading NetCDF file: 'getVarDouble' function - 'HDF error (NC_EHDFERR)'
31 次查看(过去 30 天)
显示 更早的评论
Hello,
I am trying to read in different variables from a netCDF with 'ncread', but am encountering an error when trying to call in latitude and logitude (but not with any other variables)
My code:
ncfile =('D:\sydneysDrive\imagery\POLYMER\POLYMER_output\LC08_L1TP_001017_20140508_20200911_02_T1_redo_polymer.nc')
chl = ncread(ncfile,'logchl') ;
red = ncread(ncfile,'Rw655') ;
nir = ncread(ncfile,'Rw865') ;
lon = ncread(ncfile,'longitude') ;
lat = ncread(ncfile,'latitude') ;
My error:
Error using matlab.internal.imagesci.netcdflib
The NetCDF library encountered an error during execution of 'getVarDouble' function - 'HDF error (NC_EHDFERR)'.
Error in netcdf.getVar (line 205)
data = matlab.internal.imagesci.netcdflib(funcstr,ncid,varid,varargin{:});
Error in internal.matlab.imagesci.nc/read (line 644)
data = netcdf.getVar(gid, varid);
Error in ncread (line 74)
vardata = ncObj.read(varName, varargin{:});
Error in ReadingPolymerNetCDFs (line 6)
lon = ncread(ncfile,'longitude') ;
Any help is greatly appreciated!
Sydney
0 个评论
采纳的回答
Vatsal
2023-9-26
Hi @Sydney Baratta,
I understand that you are getting the “NC_EHDFERR” error while reading variables ‘latitude’ and ‘longitude’.
Based on the error message you received ('HDF error (NC_EHDFERR)'), it is likely that the netCDF file you are working with is corrupted. To investigate further, it would be helpful to determine if the error is specific to MATLAB or if it persists when using other tools.
I recommend using third-party tools, such as the Python netcdf4 package, to read the netCDF file. This will allow you to verify if the error persists and help identify any potential issues with the file itself. You can find a tutorial on reading netCDF data using Python in the following article:
Please try using the Python netcdf4 package to read the file and observe if the same error occurs. This will provide valuable information for troubleshooting the issue further.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NetCDF 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!