Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert grib to netcdf file

Is there a way to convert a grib file into a NetCDF format on Windows?
I use a software named tkdegrib but it catches one argument by one argument whereas I want all my grib's arguments in the same file. Unfortunately, I can't use Linux.

like image 380
piecess Avatar asked Jul 01 '13 11:07

piecess


3 Answers

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!

like image 127
Rich Signell Avatar answered Sep 21 '22 05:09

Rich Signell


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
like image 39
Adrian Tompkins Avatar answered Sep 22 '22 05:09

Adrian Tompkins


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.

like image 42
Bharti Mohane Avatar answered Sep 20 '22 05:09

Bharti Mohane