[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDFJava #HMB-497600]: Reading NDFD Files



Hi Rob,

This is going to be a short answer because I'm leaving town today until May6. 
The coordinates are x and y for the NDFD type data. Once you have the file open 
as a GridDataset, then you can get the NetcdfFile associated with the 
GridDataset and get the values for x and y.

      NetcdfFile ncf = gridDataSet.getNetcdfFile();
      List<Variable> vars = ncf.getVariables();
      for (Variable var : vars) {
        System.out.println(var.getName());
      }
      Variable x = ncf.findVariable("x");
      // need to get the correct dimension here, 1072 was from my sample file
      Array data = x.read("0:1072");
      IndexIterator iter = data.getIndexIterator();
      System.out.print("x = "); 
      while (iter.hasNext()) {
        int val = iter.getIntNext();
        System.out.print(val +" ");
      }
      System.out.println();

      One also has get the y variable too.

      There are some GridCoordSys() routines to help too.

     
http://www.unidata.ucar.edu/software/netcdf-java/v2.2.22/javadoc/ucar/nc2/dt/GridCoordSystem.html

     There's probably a better way of doing this, I can revisit when I get back
Robb...


Ticket Details
===================
Ticket ID: HMB-497600
Department: Support netCDF Java
Priority: Normal
Status: Open