Page tree

GRIB-API support is being discontinued at the end of 2018. Please consider upgrading to ecCodes

Skip to end of metadata
Go to start of metadata


Get values of some keys from a GRIB file. It is similar to grib_ls, but fails returning an error code when an error occurs (e.g. key not found).


grib_get [options] grib_file grib_file ...


Force. Force the execution not to fail on error.

-p key[:{s/d/i}],key[:{s/d/i}],...
Declaration of keys to print. For each key a string (key:s) or a double (key:d) or an integer (key:i) type can be requested. Default type is string.

-F format
C style format for floating point values.

-l Latitude,Longitude[,MODE,file]
Value close to the point of a Latitude/Longitude.
Allowed values for MODE are:

  • 4 (4 values in the nearest points are printed) Default
  • 1 (the value at the nearest point is printed)
  • file (file is used as mask. The closer point with mask value>=0.5 is printed)

-P key[:{s/d/i}],key[:{s/d/i}],...
As -p adding the declared keys to the default list.

-w key[:{s/d/i}]{=/!=}value,key[:{s/d/i }]{=/!=}value,...
Where clause. Grib messages are processed only if they match all the key/value constraints. A valid constraint is of type key=value or key!=value. For each key a string (key:s) or a double (key:d) or an integer (key:i) type can be specified. Default type is string.
In the value you can also use the forward-slash character "/" to specify an OR condition (i.e. a logical disjunction)

-n namespace
All the keys belonging to namespace are printed. Some useful namespaces are: "time", "parameter", "geography" and "statistics".

-s key[:{s/d/i}]=value,key[:{s/d/i}]=value,...
Key/values to set. For each key a string (key:s) or a double (key:d) or an integer (key:i) type can be defined. By default the native type is set.


-W width
Minimum width of each column in output. Default is 10.

Mars keys are printed.

Multi-field support off. Turn off support for multiple fields in single grib message.

Copy GTS header.

GRIBEX compatibility mode.

-T T | B
Message type. T->GTS, B->BUFR. The input file is interpreted according to the message type.

Does not fail when the message has wrong length

-i index
Data value corresponding to the given index is printed. Note this index is zero-based, so the first value is at index 0.

grib_get examples

  1. grib_get fails if a key is not found.

    > grib_get -p gribname ../data/tigge_pf_ecmwf.grib2
  2. To get the step of the first GRIB message in a file: 

    > grib_get -w count=1 -p step ../data/tigge_pf_ecmwf.grib2



  • No labels