Christiane,

I suspect that you have a problem with your dependencies and this causes 
NetCDF indexing to fail.

Are you using Maven to manage your project? What is the output of "mvn 
dependency:tree"?

The NetCDF reader uses a tiny embedded H2 database to maintain an index 
of the contents of each NetCDF file. The error you see relates to 
managing this index. AbstractMethodError suggests a difference between 
the dependencies at compile time and run time (otherwise the code would 
not compile).

On GeoTools master (16-SNAPSHOT, built from 
4cc37699180815022c028893b3c78672e9898f71), if I run "mvn 
dependency:tree" in gt-netcdf, the output includes these lines:
[INFO] |  +- org.geotools.jdbc:gt-jdbc-h2:jar:16-SNAPSHOT:compile
[INFO] |  |  +- org.opengeo:geodb:jar:0.7-RC2:compile
[INFO] |  |  |  \- net.sourceforge.hatbox:hatbox:jar:1.0.b7:compile
[INFO] |  |  \- com.h2database:h2:jar:1.1.119:compile

If I run the following (based on the user guide) in either a unit test 
or main method (added in gt-netcdf):

NetCDFReader reader = null;
try {
     reader = new NetCDFReader(new File("/path/to/O3-NO2.nc"), null);
     GridCoverage2D grid = reader.read("O3", null);
     float[] value = grid.evaluate((DirectPosition) new DirectPosition2D(
             grid.getCoordinateReferenceSystem(), 10, 48), new float[1]);
     System.out.println(value[0]);
} finally {
     if (reader != null) {
         reader.dispose();
     }
}

then I see printed to standard output: 84.29942

This looks plausible to me.

Kind regards,
Ben.


On 04/10/16 11:32, [email protected] wrote:
> Hi all,
> for a project I have to import/read netcdf files with climatological and/or
> environmental data. These files are similar to some of those in the test-data
> folder of the geotools netcdf-plugin:
> https://github.com/geotools/geotools/tree/71c3cca06462c8ce6678027c043d07aacff64fc2/modules/plugin/coverage-multidim/netcdf/src/test/resources/org/geotools/coverage/io/netcdf/test-data
> For a start I tried to read the test-data files (e.g. "O3-NO2.nc") following 
> the
> instructions on the NetCDF plugin user guide:
> http://docs.geotools.org/latest/userguide/library/coverage/multidim.html.
> With this I'm able to retrieve the number of coverages in file and the 
> coverage
> names. But I can't get the data values itself, e.g. the following line:
>                  // Selection of the coverage associated to the name
>                  GridCoverage2D grid = reader.read(first, null);
> throws the following error:
> Okt 03, 2016 10:57:04 PM org.geotools.coverage.io.netcdf.NetCDFAccess access
> SCHWERWIEGEND: Failed to access the NetCDF source
> java.lang.AbstractMethodError: 
> net.sourceforge.hatbox.jts.UpdateTrigger.close()V
>      at org.h2.schema.TriggerObject.close(TriggerObject.java:433)...
> Same when using other netcdf files or other gt-netcdf functions (e.g.
> reader.getCoordinateReferenceSystem(first)). I'm not very familiar with NetCDF
> and geotools either. Although I read lots of documentation (e.g. UNIDATA
> provides) in the last few weeks, apparently I missed some important steps?
> Any help/assistance on this subject would be greatly appreciated.
> Thank you in advance,
> Christiane
> Following the complete output messages:
> 23:28:37.073 [main] DEBUG Main - Summary information about GeoTools and the
> current environment:
> 23:28:37.169 [main] DEBUG Main - GeoTools version 16-SNAPSHOT (built from
> r99f8c073594af14aa03b144956d54835c1d768a3)
> Java version: 1.8.0_101
> Operating system: Windows 10 10.0
> GeoTools jars on classpath:
> Okt 03, 2016 11:28:38 PM org.geotools.imageio.netcdf.utilities.NetCDFUtilities
> <clinit>
> INFORMATION: Value of Check Coordinate Plugins:null
> Okt 03, 2016 11:28:38 PM org.geotools.imageio.netcdf.utilities.NetCDFUtilities
> <clinit>
> INFORMATION: Should check for coordinate handler plugins:false
> 23:28:38.778 [main] INFO serverStartup - Nc4Iosp: NetCDF-4 C library loaded
> (jna_path='null', libname='netcdf').
> 23:28:38.787 [main] DEBUG ucar.nc2.jni.netcdf.Nc4Iosp - Netcdf
> nc_inq_libvers='4.4.1 of Jun 28 2016 14:35:06 $' isProtected=true
> 23:28:38.954 [main] DEBUG ucar.nc2.NetcdfFile - Using IOSP
> ucar.nc2.iosp.netcdf3.N3raf
> 23:28:39.244 [main] DEBUG ucar.nc2.NetcdfFile - Using IOSP
> ucar.nc2.iosp.netcdf3.N3raf
> 23:28:40.311 [main] INFO hsqldb.db.HSQLDB4AD417742A.ENGINE - dataFileCache 
> open
> start
> Okt 03, 2016 11:28:40 PM org.geotools.coverage.io.netcdf.NetCDFReader <init>
> INFORMATION: ACCEPTED: O3-NO2.nc
> 23:28:40.858 [main] DEBUG Main - NetCDF store plugin
> 23:28:40.858 [main] DEBUG Main - Number of coverages in file: 2
> 23:28:40.858 [main] DEBUG Main - NO2
> 23:28:40.858 [main] DEBUG Main - O3
> 23:28:40.858 [main] DEBUG Main - start reading coverage: NO2
> 23:28:40.858 [main] DEBUG Main -
> org.geotools.coverage.io.netcdf.NetCDFReader@1df223b
> Okt 03, 2016 11:28:50 PM org.geotools.coverage.io.netcdf.NetCDFAccess access
> SCHWERWIEGEND: Failed to access the NetCDF source
> java.lang.AbstractMethodError: 
> net.sourceforge.hatbox.jts.UpdateTrigger.close()V
>      at org.h2.schema.TriggerObject.close(TriggerObject.java:433)
>      at org.h2.engine.Database.close(Database.java:1271)
>      at org.h2.engine.Database.removeSession(Database.java:1170)
>      at org.h2.engine.Session.close(Session.java:815)
>      at org.h2.jdbc.JdbcConnection.close(JdbcConnection.java:383)
>      at
> org.apache.commons.dbcp.DelegatingConnection.close(DelegatingConnection.java:247)
>      at
> org.apache.commons.dbcp.PoolableConnection.reallyClose(PoolableConnection.java:122)
>      at
> org.apache.commons.dbcp.PoolableConnectionFactory.destroyObject(PoolableConnectionFactory.java:628)
>      at
> org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1562)
>      at
> org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
>      at
> org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
>      at
> org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
>      at
> org.geotools.data.jdbc.datasource.AbstractManageableDataSource.getConnection(AbstractManageableDataSource.java:48)
>      at 
> org.geotools.jdbc.JDBCDataStore.createConnection(JDBCDataStore.java:2063)
>      at 
> org.geotools.jdbc.JDBCDataStore.createTypeNames(JDBCDataStore.java:978)
>      at 
> org.geotools.data.store.ContentDataStore.entry(ContentDataStore.java:581)
>      at
> org.geotools.data.store.ContentDataStore.ensureEntry(ContentDataStore.java:617)
>      at
> org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:393)
>      at
> org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:360)
>      at
> org.geotools.data.store.ContentDataStore.getSchema(ContentDataStore.java:344)
>      at
> org.geotools.coverage.io.catalog.CoverageSlicesCatalog.getSchema(CoverageSlicesCatalog.java:516)
>      at
> org.geotools.imageio.netcdf.VariableAdapter.updateDimensions(VariableAdapter.java:569)
>      at
> org.geotools.imageio.netcdf.VariableAdapter.initSpatialElements(VariableAdapter.java:532)
>      at 
> org.geotools.imageio.netcdf.VariableAdapter.init(VariableAdapter.java:470)
>      at
> org.geotools.imageio.netcdf.VariableAdapter.<init>(VariableAdapter.java:1038)
>      at
> org.geotools.imageio.netcdf.NetCDFImageReader.getCoverageDescriptor(NetCDFImageReader.java:568)
>      at 
> org.geotools.coverage.io.netcdf.NetCDFSource.<init>(NetCDFSource.java:52)
>      at 
> org.geotools.coverage.io.netcdf.NetCDFAccess.access(NetCDFAccess.java:167)
>      at
> org.geotools.coverage.io.netcdf.NetCDFReader.getGridCoverageSource(NetCDFReader.java:649)
>      at 
> org.geotools.coverage.io.netcdf.NetCDFReader.read(NetCDFReader.java:485)
>      at Main.main(Main.java:84)
> 23:28:50.115 [main] DEBUG Main - Reader closed.
> Exception in thread "main" java.lang.IllegalArgumentException: Argument 
> "value"
> should not be null.
>      at 
> org.geotools.util.SoftValueHashMap.ensureNotNull(SoftValueHashMap.java:140)
>      at org.geotools.util.SoftValueHashMap.put(SoftValueHashMap.java:281)
>      at
> org.geotools.coverage.io.netcdf.NetCDFReader.getGridCoverageSource(NetCDFReader.java:651)
>      at 
> org.geotools.coverage.io.netcdf.NetCDFReader.read(NetCDFReader.java:485)
>      at Main.main(Main.java:84)
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>
>
>
> _______________________________________________
> GeoTools-GT2-Users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>

-- 
Ben Caradoc-Davies <[email protected]>
Director
Transient Software Limited <http://transient.nz/>
New Zealand

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to