If i have a grib2 file that contains information for whole world (for some parameters) and I want to extract data from it using wgrib2 based on latitude and longitude given by user (client software to server). I tried following command but I am getting complete grib2 file only:
wgrib2.exe input.grb -undefine out-box 10:90 -10:10 -grib output.grb
Please tell me where am I going wrong? Thanks.
This is still the top hit on Google, so even though it is a bit old, here is a more detailed explanation.
First, you need wgrib2
from the National Weather Service Climate Prediction Centre. (The installation of that is straightforward, but not too well explained. See this page, or this gist for help.)
Next, you need to use the lola function (for LOngitude-LAtitude grid).
You need to give wgrib2
several arguments:
bin
for binary, text
for simple text, spread
for spreadsheet format, or grib
for grib2).For example:
wgrib2 input.grb 220:100:1 20:50:1 output.grb2 grib
will create an output file that covers north america (220 E - 320 E; 20 N - 70 N) at 1 degree intervals in both directions.
Rob