Hi, I'm trying to load some NetCDF files via GeoTools but this results in DataSourceException, whose root cause is:
Caused by: java.lang.IllegalArgumentException: Unable to init temporal domain from CoordinateVariable that does not have a TemporalCRS I believe the NetCDF are valid, because I'm able to read them via the UCAR NetCDF Java implementation: https://www.unidata.ucar.edu/software/thredds/current/netcdf-java/tutorial/NetcdfFile.html I still prefer to read these files via GeoTools because I'm looking to perform some transformations we've already developed (input files were previously GeoTIFF). An example of a NetCDF file that fails can be downloaded here: https://m-innvoincy.box.com/s/oh54qohyw52sh9ydygbq35lsp9zo0v4q Below is the code I used: package com.mi.tests; import java.io.File; import org.geotools.coverage.grid.GridCoverage2D; import org.geotools.coverage.io.netcdf.NetCDFReader; import org.geotools.referencing.crs.DefaultGeographicCRS; import org.geotools.util.factory.Hints; public class GeoToolsNetCDFJavaTest { static { System.setProperty("netcdf.coordinates.enablePlugins", "true"); } public static void main(String[] args) throws Exception { String resourceUrl = "/Users/yaniv/example.nc"; File file = new File(resourceUrl); NetCDFReader netCDFReader = new NetCDFReader(file, new Hints(Hints.CRS, DefaultGeographicCRS.WGS84)); String[] coverageNames = netCDFReader.getGridCoverageNames(); for (String coverageName : coverageNames) { GridCoverage2D grid = netCDFReader.read(coverageName, null); System.out.println("Name: " + coverageName + ", dimension: " + grid.getDimension()); } } } And the full stack trace: Exception in thread "main" org.geotools.data.DataSourceException: Unable to connect at org.geotools.coverage.io.netcdf.NetCDFReader.<init>(NetCDFReader.java:160) at com.mi.tests.GeoToolsNetCDFJavaTest.main(GeoToolsNetCDFJavaTest.java:21) Caused by: org.geotools.data.DataSourceException: java.io.IOException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Unable to init temporal domain from CoordinateVariable that does not have a TemporalCRS at org.geotools.coverage.io.netcdf.NetCDFAccess.<init>(NetCDFAccess.java:139) at org.geotools.coverage.io.netcdf.NetCDFDriver.connect(NetCDFDriver.java:92) at org.geotools.coverage.io.impl.DefaultFileDriver.process(DefaultFileDriver.java:228) at org.geotools.coverage.io.netcdf.NetCDFReader.<init>(NetCDFReader.java:157) ... 1 more Caused by: java.lang.RuntimeException: java.io.IOException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Unable to init temporal domain from CoordinateVariable that does not have a TemporalCRS at org.geotools.imageio.netcdf.NetCDFImageReader.setInput(NetCDFImageReader.java:288) at javax.imageio.ImageReader.setInput(ImageReader.java:380) at org.geotools.coverage.io.netcdf.NetCDFAccess.<init>(NetCDFAccess.java:128) ... 4 more Caused by: java.io.IOException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Unable to init temporal domain from CoordinateVariable that does not have a TemporalCRS at org.geotools.imageio.netcdf.NetCDFImageReader.initIndex(NetCDFImageReader.java:400) at org.geotools.imageio.netcdf.NetCDFImageReader.init(NetCDFImageReader.java:533) at org.geotools.imageio.netcdf.NetCDFImageReader.setInput(NetCDFImageReader.java:286) ... 6 more Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Unable to init temporal domain from CoordinateVariable that does not have a TemporalCRS at org.geotools.imageio.netcdf.NetCDFImageReader.getCoverageDescriptor(NetCDFImageReader.java:629) at org.geotools.imageio.netcdf.NetCDFImageReader.initIndex(NetCDFImageReader.java:338) ... 8 more Caused by: java.lang.IllegalArgumentException: Unable to init temporal domain from CoordinateVariable that does not have a TemporalCRS at org.geotools.imageio.netcdf.VariableAdapter.initAdditionalDomain(VariableAdapter.java:828) at org.geotools.imageio.netcdf.VariableAdapter.initCRS(VariableAdapter.java:746) at org.geotools.imageio.netcdf.VariableAdapter.initSpatialElements(VariableAdapter.java:504) at org.geotools.imageio.netcdf.VariableAdapter.init(VariableAdapter.java:476) at org.geotools.imageio.netcdf.VariableAdapter.<init>(VariableAdapter.java:1109) at org.geotools.imageio.netcdf.NetCDFImageReader.getCoverageDescriptor(NetCDFImageReader.java:627) ... 9 more Thanks in advance, Yaniv -- Best regards, *Yaniv Ben-Yosef* *CTO, Milan InnoVincY B.V.* *M* +972(54)670 9743 | *S* yaniv.benyosef | *E* ybyo...@m-innovincy.com <ybyo...@m-innovincy.com> *The Netherlands* | Kapteynstraat 1 | 2201BB NOORDWIJK *Rwanda* | *AgriLift Ltd* | KG 536 Axiom Building, behind Telecom House | KIGALI *Confidential - Do not duplicate or distribute without written permission from Milan Innovincy B.V© Milan Innovincy B.V, 2017. Any third party right are hereby acknowledged. All rights reserved. Please consider the environment – do you really need to print this email?*
_______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users