Skip Navigation Links 
NOAA logo - Click to go to the NOAA home page National Weather Service   NWS logo - Click to go to the NWS home page
Climate Prediction Center

About Us
   Our Mission
   Who We Are

Contact Us
   CPC Information
   CPC Web Team

HOME > Monitoring_and_Data > Oceanic and Atmospheric Data > Reanalysis: Atmospheric Data > wgrib2-lon

wgrib2: -lon


The -lon option prints the value of the grid point closest to the specified longitude latitude. The latitude-longitude of the grid point are also printed. If you use the verbose mode, the grid coordinates (i,j) and the number of the element are also printed. The -lon option can be repeated to save processing time.

-sh-2.05b$ wgrib2 eta.t00z.awphys18.grb2 -d 1 -s -lon 249 39 -lon 255 33
1:0:d=2003090300:MSLET:mean sea level:18 hour fcst:lon=249.035,lat=38.9912,val=101685:

-sh-3.00$ wgrib2 rtma.t12z.2dvaranl_ndfd.grb2.c2 -d 1 -v -lon -120 30
In the latter example, the verbose mode has been set and the inventory includes both the value, location and its grid coordinates; i.e., the 220037th element in the array and its coordinates are (72,206). Note that these coordinates are after the data has been converted into a WE:SN scan order. Both the i, ix and iy start with a value of one.


      LONGITUDE = 0 .. 360
      LATITUDE = -90 .. 90

      If the verbosity is 0, the print out the longitude and
        latitude of the nearest grid point as well as the grid value.

      If the verbosity is 1 or higher, the prints out the longitude and
        latitude of the nearest grid point, the index (i) to the data,
        the grid coordinates (ix,iy) as well as the grid point value.

        i = 1..number of grid points
        ix = 1..nx
        iy = 1..ny


$ wgrib2 test.grb2 -s -lon -90 20
1:0:d=2005090200:HGT:1000 mb:60 hour fcst:lon=270,lat=20,val=121.3
2:133907:d=2005090200:HGT:975 mb:60 hour fcst:lon=270,lat=20,val=344.4
3:263511:d=2005090200:HGT:950 mb:60 hour fcst:lon=270,lat=20,val=573
4:389058:d=2005090200:HGT:925 mb:60 hour fcst:lon=270,lat=20,val=806.5

Want Speed?

You want extract the values for a 1000 different points. So you call wgrib2 1000 times and complain that wgrib2 is slow. Well decoding a jpeg2000 compressed file 1000 times does take time. It's better to add a 1000 -lon options to the command line and only decode the file once.

The number of -lon options on a command line is limited by a compile-time option. Try running wgrib2 -config and look for the line "maximum number of arguments on command line:". The current value is 5000 which allows you 5000 words on the command line. Each -lon option takes 3 words, so that gives you about 1600 -lon options you can run on one line. Of course, limitations such as the maximum line length or maximum number of continuations may stop you first.

See also: -lola See also: -config

NOAA/ National Weather Service
National Centers for Environmental Prediction
Climate Prediction Center
5830 University Research Court
College Park, Maryland 20740
Climate Prediction Center Web Team
Page last modified: Jan 20, 2016
Disclaimer Privacy Policy