Project

General

Profile

Correct Lonlat Grid When Convertng from NetCDF to GRIB

Added by Aaron Perry almost 7 years ago

I am trying to convert a lonlat file from NetCDF to GRIB using the following code:

cdo -f grb -setparam,0.0 -setlevel,2 -setltype,103 -setmissval,-999.99 in.nc out.grib

When I convert to GRIB and display the file, the grid is skewed from the input NetCDF grid. Below is the grid info from the NetCDF and output GRIB files, including the matching images:

NetCDF: #
  1. gridID 1 #
    gridtype = lonlat
    gridsize = 1841644
    xname = lon
    xlongname = Longitude
    xunits = degrees_east
    yname = lat
    ylongname = Latitude
    yunits = degrees_north
    xsize = 1802
    ysize = 1022
    xfirst = -80.0001
    xinc = 0.00833333
    yfirst = 39.9919
    yinc = 0.00833333
GRIB: #
  1. gridID 1 #
    gridtype = lonlat
    gridsize = 21922684
    xname = lon
    xlongname = longitude
    xunits = degrees_east
    yname = lat
    ylongname = latitude
    yunits = degrees_north
    xsize = 7022
    ysize = 3122
    xfirst = 235
    xinc = 0.008
    yfirst = 23.992
    yinc = 0.007999
grads_file (194 KB) grads_file This is how the file should look (from the input NetCDF file), as displayed in GrADS
cdo_file (110 KB) cdo_file This is the output file after converting from NetCDF to GRIB

Replies (1)

RE: Correct Lonlat Grid When Convertng from NetCDF to GRIB - Added by Aaron Perry almost 7 years ago

Correction to the NetCDF grid size: #
  1. gridID 1 #
    gridtype = lonlat
    gridsize = 21922684
    xname = lon
    xlongname = Longitude
    xunits = degrees_east
    yname = lat
    ylongname = Latitude
    yunits = degrees_north
    xsize = 7022
    ysize = 3122
    xfirst = -125
    xinc = 0.00833333
    yfirst = 23.9919
    yinc = 0.00833333
    (1-1/1)