[netcdf-java] NetCDF4 Example

Hi All!!
   So I'm new to NetCDF, I had to write some files and I've been able to do
it with Netcdf 2.2.22. Then I realized that I needed a String Variable and
that NetCDF version doesn't have support for this.
And I can't understand how to create a netcdf file. I've read the docs, and
I've been able to create the file but I have problems adding Variables.
Basically in the old version If I had a 2 dimensional variable I used to do:

int[] index2d = {latIndex, longIndex}; //Latitude and Longitude
Variable amp = nc.get(ampP.getName()); //the name of the ProtoVar
amp.setDouble(index2d, wth.getAmp()); //origin and value.


I don't know how to translate this in the new version, I'm trying
int[] index2d = {latIndex, longIndex};
Array arrAmp = Array.factory(DataType.DOUBLE,  new int[] {0}, new
double[]{wth.getAmp()});
nc.write(ampP.getName(), index2d, arrAmp);


But it didn't work. Anybody has an example of how to write netCDF 4 files
with java?

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