I'm using the geotools test cases NetCDF-4 test file temperatureisobaricNC4.nc. Data file is here; https://github.com/geotools/geotools/blob/42c4cc0c3d850b1dea50c07108f171aace35a798/modules/plugin/coverage-multidim/netcdf/src/test/resources/org/geotools/coverage/io/netcdf/test-data/temperatureisobaricNC4.nc It gives exceptions when trying to add it as a datastore. The actual exception is; Caused by: java.lang.ClassCastException: java.lang.Double cannot be cast to java.util.Date at org.geotools.imageio.netcdf.VariableAdapter.getTimeValueByIndex(VariableAdapter.java:1292) at org.geotools.imageio.netcdf.VariableAdapter.createFeature(VariableAdapter.java:1172) at org.geotools.imageio.netcdf.VariableAdapter.getFeatures(VariableAdapter.java:1138) at org.geotools.imageio.netcdf.NetCDFImageReader.initIndex(NetCDFImageReader.java:333) This is because it's getting confused as to which dimension is the Time dimension. Here's the info from ncdump; netcdf temperatureisobaricNC4 { dimensions: isobaric = 2 ; time = 1 ; lat = 65 ; lon = 47 ; variables: double isobaric(isobaric) ; isobaric:long_name = "isobaric" ; isobaric:description = "isobaric" ; isobaric:units = "Pa" ; double time(time) ; time:long_name = "time" ; time:description = "time" ; time:units = "seconds since 1970-01-01 00:00:00 UTC" ; float lat(lat) ; lat:long_name = "latitude" ; lat:units = "degrees_north" ; float lon(lon) ; lon:long_name = "longitude" ; lon:units = "degrees_east" ; float Temperature_isobaric(isobaric, time, lat, lon) ; ... Looks like the COARDS conventions say; Order of dimensions: If any or all of the dimensions of a variable have the interpretations of "date or time" (a.k.a. "T"), "height or depth" (a.k.a. "Z"), "latitude" (a.k.a. "Y"), or "longitude" (a.k.a. "X") then those dimensions should appear in the relative order T, then Z, then Y, then X in the CDL definition corresponding to the file. Geotools is assuming T, Z, Y, Z ordering, but the dataset is Z, T, Y, X. The test case data file doesn't appear to be COARDS. The test cases for NetCDF4 support is very very simple - they just check that a reader can be created. |