How to read all remote sensing images of hdf4 and hdf5

hello everybody,is there a way to use the Java API to read remote sensing images of all hdf4 and hdf5 formats?
when i use snap api to read hdf4 data,
Product product=ProductIO.readProduct(“C:\Users\26078\Desktop\GLASS09A01.V02.A2014001.h27v05.2015360.hdf”);
the eclipse reports an error:
java.lang.UnsatisfiedLinkError: no jhdf5 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at ncsa.hdf.hdf5lib.H5.loadH5Lib(H5.java:339)
at ncsa.hdf.hdf5lib.H5.(H5.java:266)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.esa.snap.dataio.hdf5.Hdf5ProductWriterPlugIn.loadHdf5Lib(Hdf5ProductWriterPlugIn.java:148)
at org.esa.snap.dataio.hdf5.Hdf5ProductWriterPlugIn.(Hdf5ProductWriterPlugIn.java:45)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at org.esa.snap.SnapCoreActivator.loadServices(SnapCoreActivator.java:60)

Is it not supported by snap API?
what should i do?
thank you for your help!

1 Like

I think the reason is that the HDF libraries are not found when you simply put the jars on your classpath.
You can use the following java properties to define the path:

-Dncsa.hdf.hdflib.HDFLibrary.hdflib=c:\path\to\jhdf.dll
-Dncsa.hdf.hdf5lib.H5.hdf5lib=c:\path\to\jhdf5.dll

You can find these libraries in lib-hdf-2.7.1.jar

hi marpet:
I try to use the desktop SNAP to open this .HDF image,however ,it doesn’t work,Doesn’t SNAP support all .hdf images? is
there a way of using java API to read all .hdf images?
THANK you for your reply!

No, not all hdf files are supported. For some files the supported might be limited and some might not open at all.
But there is a plugin point. So you could write a Plugin and extend SNAP with the capability you need.
Here you can find a little introduction: https://senbox.atlassian.net/wiki/spaces/SNAP/pages/10584125/How+to+create+a+new+product+reader

A post was split to a new topic: How to read Cosmo-SkyMED data