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
-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.
-lon LONGITUDE LATITUDE
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
Old vs New
The original code for the
-lon option used the internal geolocation package.
This package could compute the lat/lon of the grid points but
nothing else. To find the grid point closest to a specified
lat/lon, the distance to every grid point had to be calculated.
Later, a short cut was added for lat-lon grids. Finally the
geolocation packages gctpc and Proj4 have inverse functions
which allow you to find the closest grid point to specified point
for the the supported grids. For unsupported grids like the
Gaussian grid and staggered grids, the original brute force
code is used. You can turn off the new code by the
-gctpc 0 option. The old code did
not know about grid domains and would find the closest point
even if the point were outside of the grid domain. The
gctpc-based closest will return a lat=lon=999 to signal an
intial point outside of the domain.
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