Hi Yaniv, sorry for the late answer on this mail. I didn't notice that before. (You may have already solved in the meantime)
Anyway, are you able to "view" the data using ToolsUI (from UCAR) -> FeatureTypes -> Grids -> GridViewer? This is a typical check I do to have a quick idea of whether the file can be properly handled by GeoTools/GeoServer. If neither ToolsUI can display the data, supporting it into GT can be a bit trickier. It looks like your sample data exposes some temporal domain but it then has some issues in referring the underlying temporal coordinate variable. Do you also have an "ncdump" output for that file? Please, let us know. Regards, Daniele On Fri, Feb 1, 2019 at 11:10 AM Yaniv Ben-Yosef <ya...@m-innovincy.com> wrote: > 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 > -- Regards, Daniele Romagnoli == GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Daniele Romagnoli Senior Software Engineer GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) Italy phone: +39 0584 962313 fax: +39 0584 1660272 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.
_______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users