Convert grib to netcdf file

I would use Unidata's NetCDF-Java library.

It reads GRIB and GRIB2 files (as well as many others), and can write NetCDF files. And since it's Java, you don't have to build anything, and it works on all platforms. There is a ToolsUI application that you can use if you want a GUI, but more likely you want to do it from the command line using something like this:

 java -Xmx512m -classpath netcdfAll-4.3.jar ucar.nc2.dataset.NetcdfDataset -in infile.grib2 -out outfile.nc

Good luck!


1. Climate data operators

If you have Windows 10 installed, it is now very easy to simply install ubuntu directly under windows as a subsystem (no wineserver or cygwin required), and then you can install CDO very easily with

sudo apt install cdo

once done you can do:

cdo -f nc copy file.grb file.nc

2. ECCODES

ECMWF has developed a new package called eccodes which includes command line operators for this kind of task. This is the preferred method if you have grib data with more than one time axis such as S2S output, where you have the time of the forecast start and the forecast step and possibly even the hindcast start date. In those cases CDO fails.

You can install it under windows using this guide: https://confluence.ecmwf.int/pages/viewpage.action?pageId=70949236

Or easily on the linux subsystem with sudo apt-get (on MAC OSX you can install with: brew install eccodes).

Then from the subsystem command line you can simply type:

grib_to_netcdf -o out.nc in.grb

There is GDAL utility gdalwarp, which can convert grib dataset into netCDF dataset.

The command for conversion is

gdalwarp -overwrite -to SRC_METHOD=NO_GEOTRANSFORM -t_srs EPSG:4326 input.grb -of netCDF output.nc

For more options of this utility can be searched on this link.