Re: [netcdf-java] GRIB-2-netCDF Projection Question

Hi Bryan:

1. The classes you are working with in NetCDF-Java 4.0 are no longer supported. Please look at ucar.nc2.grib.* classes in NetCDF-Java 4.3.

2. NetCDF-Java does not support writing GRIB files, only reading them. So we support GRIB -> netcdf/CF, but not the other way around. In principle, if you understand the CF conventions, you can write the correct GRIB GDS from them.

3. The convention that projection x and y values must be positive is not used. Thats more of a GIS thing and is rather artificial; one typically has to add "false_northing" and "false_easting" to make it true.

4. The "origin of the projection" may also be different than what you are used to. It is essentially the place where x=0, y=0 in the projection defined by the LambertConformal class; LA1 and LO1 is the position of one of the corners of the grid. Theres no documentation other than the code for GRIB, but you might find this helpful:


On 6/25/2012 12:14 PM, Rockwood, Bryan wrote:

As part of the process of creating a GRIB1 file from subgridded netCDF data 
generated by the NetCDF-Java 4.0 API (long story), I had a difficult time 
figuring out how the X and Y values from the netCDF were calculated.  Since 
there were negative X and Y values, it appeared that the projection used to 
calculate X and Y were not grid based.  So, I obtained the Java netCDF source 
and proceeded to debug through the code.  After some exploring, I found a class 
called GridHorizCoordSys in the package ucar.nc2.iosp.grid.  In said class is a 
private method called makeLC and the first thing it does is create a projection 
for the GRIB record.  Now here's where I'm confused.  This is the code in 

  proj = new LambertConformal(



Looking at the javadoc for the LambertConformal constructor, the first two 
parameters should be the latitude and longitude origin of the coordinate 
system.  In my experience when dealing with Lambert Conformal grids, this is 
typically GridDefRecord.LA1 and GridDefRecord.LO1, respectively, from the GRIB 
GDS.  The code above is using GridDefRecord.LATIN1 and GridDefRecord.LOV 
instead.  Once I found out how the projection was being created, it was then 
possible to get the LA1 and LO1 from the X and Y within the netCDF to create a 
valid GDS for the GRIB data I'm generating.  My questions are as follows:

Why use the LATIN1 and LOV to set the lat and lon origin of the projection 
instead of LA1 and LO1?

Is this documented someplace?  I'm curious how someone such as myself would 
know to create a projection like this without debugging through the code.

Bryan Rockwood

netcdf-java mailing list
For list information or to unsubscribe, visit:

  • 2012 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: