loader image

What is a GRIB file?

[vc_row][vc_column][vc_column_text disable_pattern=”false” css=”.vc_custom_1633945405565{margin-bottom: 0px !important;background-color: #ffffff !important;background-position: center !important;background-repeat: no-repeat !important;background-size: contain !important;}”]

What is a GRIB file?

GRIB stands for General Regularly-distributed Infomation in Binary form. It is a data format used in meteorology to store weather data. It was first defined in 1985 by the World Meteorological Organization (WMO).
GRIB files were designed to exchange and store large volumes of gridded data and are used in Numerical Prediction models such as Weather Research Forecast (WRF) model, in reanalysis data (ERA5 and CFSR), and in forecast data, such as the NOOA Global Forecast System (GFS) or the ECMWF Integrated Forecasting System (IFS).
GRIB files are machine-independent and require software for encoding and decoding.

How to read a GRIB file?

A binary file has its information stored in ones and zeros, which means if we try to open the file with a text editor such as Notepad we won’t be able to read any information. On the other hand, this type of format provides faster access to the data and uses less memory than a plain text format.
GRIB files are a collection of self-defining messages. Each message contains several sections:

  • Indicator
  • Product definition
  • Grid description
  • Bit map
  • Binary data
  • End of message coded with “7777”

Each message stands alone as meaningful data so a file may contain one or more GRIB messages. Collections of GRIB messages can be appended to each other.
Currently, there are two different coding standards: GRIB edition 1 and GRIB edition 2. The major differences are in the structure of the messages.


There are several tools to operate with GRIB files. The most popular command-line applications are:

There are also some graphical visualization packages such as ArcGIS, GrADS, Panoply, and Metview.

Examples of operations with GRIB files:

# Dump the content of a GRIB file 
grib_dump input.grb

# List the content of a GRIB file 
grib_ls -n parameter input.grb

# Select U wind component     
grib_get_data -w shortName=u input.grb      

# Select the fields at 100 hPa level 
grib_copy -w level=100 input.grb output.grb

# Find the nearest grid point at latitude 41.4 and longitude 2.2 
grib_ls -l 41.4,2.2 input.grb

# Select a region defined by two latitudes [41.4, 42.5] and two longitudes [1.5, 2.2] 
cdo -s sellonlatbox,1.5,2.2,41.4,42.5 input.grb output.grb

# Look up data values for a location [41.4,2.2] and time [20210903 08:00]  
grib_ls -l 41.4,2.2,1 -w dataDate=20210903,dataTime=0800 -p shortName input.grib
cdo -outputtab,lon,lat,date,time,value -selyear,2021 -selmonth,09 -selday,03 -seltime,08:00 -remapnn,lon=2.2_lat=41.4 input.grb

# Open a GRIB file in NCL
f = addfile("input.grb","r")

# Convert a GRIB file to NetCDf file
cdo -f nc copy file.grb out.nc 
grib_to_netcdf -o out.nc file.grb


Leave a Comment

Your email address will not be published. Required fields are marked *