How to open GRIB2 file using ncgeodatset?
11 views (last 30 days)
Show older comments
Zhou Ci
on 26 May 2022
Answered: Jacob Halbrooks
on 25 Sep 2024
Hi everyone,
I am trying to open a 'GRIB2' file using ncgeodataset. But I am not able to do it.
fname = 'E:\NCEP\fnl_20170603_06_00.grib2'
ds = ncgeodataset(fname);
After I run above two lines, these are the results. Can somebody tell me what is the issue here. Thank you
fname =
'E:\NCEP\fnl_20170603_06_00.grib2'
2022-05-26 19:40:45,657 [main] WARN ucar.nc2.grib.grib2.Grib2CollectionBuilder - GribCollection fnl_20170603_06_00.grib2: invalid index
2022-05-26 19:40:45,657 [main] WARN ucar.nc2.grib.GribCollection - Failed to delete E:\NCEP\fnl_20170603_06_00.grib2.ncx
Warning: Escaped character '\N' is not valid. See 'doc sprintf' for supported special characters.
> In ncdataset (line 95)
In cfdataset (line 59)
In ncgeodataset (line 74)
Error using ncdataset (line 97)
Failed to open E:
Error in cfdataset (line 59)
obj = obj@ncdataset(url);
Error in ncgeodataset (line 74)
obj = obj@cfdataset(url);
Caused by:
Error using ncdataset (line 81)
Java exception occurred:
java.lang.UnsupportedOperationException: This is supposed to be overridden by subclasses.
at com.google.protobuf.GeneratedMessage.getUnknownFields(GeneratedMessage.java:262)
at ucar.nc2.grib.GribCollectionProto$Record.getSerializedSize(GribCollectionProto.java:162)
at com.google.protobuf.CodedOutputStream.computeMessageSizeNoTag(CodedOutputStream.java:916)
at com.google.protobuf.CodedOutputStream.computeMessageSize(CodedOutputStream.java:668)
at ucar.nc2.grib.GribCollectionProto$VariableRecords.getSerializedSize(GribCollectionProto.java:657)
at com.google.protobuf.AbstractMessageLite.toByteArray(AbstractMessageLite.java:70)
at ucar.nc2.grib.grib2.Grib2CollectionBuilder.createIndex(Grib2CollectionBuilder.java:558)
at ucar.nc2.grib.grib2.Grib2CollectionBuilder.createIndex(Grib2CollectionBuilder.java:415)
at ucar.nc2.grib.grib2.Grib2CollectionBuilder.readOrCreateIndex(Grib2CollectionBuilder.java:157)
at
ucar.nc2.grib.grib2.Grib2CollectionBuilder.readOrCreateIndexFromSingleFile(Grib2CollectionBuilder.java:77)
at ucar.nc2.grib.GribIndex.makeGribCollectionFromSingleFile(GribIndex.java:123)
at ucar.nc2.grib.grib2.Grib2Iosp.open(Grib2Iosp.java:310)
at ucar.nc2.NetcdfFile.<init>(NetcdfFile.java:1499)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:887)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:496)
at ucar.nc2.dataset.NetcdfDataset.openOrAcquireFile(NetcdfDataset.java:693)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:424)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:407)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:392)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:379)
1 Comment
jessupj
on 26 May 2022
Edited: jessupj
on 26 May 2022
I think this is an external tool (https://github.com/nctoolbox). You're better off asking around the developer instead of this community, as it's probbaly not a matlab-itself problem.
(My guess is opendap problems or an incompatible JVM version. if your gribfile is local, have you tried converting it to netcdf in ncl and loading it with the matlab function ncread? That way, it's at least in 'matlab' rather than a 3rd party tool and you're likely to get more help here.)
Accepted Answer
Jacob Halbrooks
on 25 Sep 2024
As of R2023b, you can read data from a GRIB file (.grb, .grib, .grib2) using the Mapping Toolbox readgeoraster function. You can also get information about a GRIB file by using the georasterinfo function. These functions were enhanced in R2024b to support GRIB files that use CCSDS compression.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!