Re: no coordinate systems/axis in netcdf file - help

Mark Rehbein wrote:


I am using the netcdf java API to read data from a large netcdf file.

I have been able to read data from the file using the
read(int[], int[]) method on ucar.nc2.Variable

However the 2 int[] arguments on the read method must have values
specified in 0 based array indices. I would prefer to specify the values
as Latitude, Longitude and Date/time.

So I started using:


I first called:

getCoordinateAxes() method on ucar.nc2.dataset.NetcdfDataset and found
there were zero axes.

I then called:

getCoordinateSystems() method on ucar.nc2.dataset.NetcdfDataset and found
there were zero coordinate systems.

I even called getCoordinateAxes() and getCoordinateSystems() methods on
each ucar.nc2.dataset.VariableDS found in the dataset and still found zero
axes and coordinate systems.

My question is, do I need to use NetcdfDataset (and
ucar.nc2.dataset.VariableDS) to be able to specify Latitude, Longitude and
Date to a read method? And if so, how do I set up the coordinate axis
and/or coordinate systems on my netcdf file using the netcdf-java API?

Or am I completely on the wrong track?

The netcdf file has the following dimensions:


The netcdf file has the following variables:

LONGITUDE      (rank=1,shape=1600,datatype=double)
LONGITUDEedges (rank=1,shape=1601,datatype=double)
LATITUDE       (rank=1,shape=2100,datatype=double)
LATITUDEedges  (rank=1,shape=2101,datatype=double)
TAXIS          (rank=1,shape=159,datatype=double)
SST_AVE        (rank=3,shape=159,2100,1600,datatype=float)

Any help provided would be greatly appreciated.

Thanks for your time,

I apologize for the state of the documentation. The library is still alpha, and is being tweaked and improved. I expect a beta release in early June.

The part you are missing is the Convention parsing code, which knows how to identify the coordainet axes. If your file has Conventions, and we already have parsing code, the following should work:

try {
 String uriString = ; // file:, dods:, http:, or local filename
NetcdfFile ncfile = ucar.nc2.dataset.NetcdfDataset.factory( uriString, null);
 NetcdfDataset ds = ucar.nc2.dataset.conv.Convention.factory( ncfile);
} catch (IOException ioe) { }

there is a default parser that uses coordinate variables, and guesses at common usage, so it may still work for you.

you can send me a sample file if you want me to have a look.

Also download the user manual and look at chapter 3:

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