Issues reading images with snappy


#1

Hello,

I have just updated to SNAP 6.0-PREVIEW4 on my Linux machine.
In my python scripts (using the snappy library), I open images using the following command:

from snappy import ProductIO sc_im = ProductIO.readProduct(image_path)

Whilst this command works with Sentinel 3 OLCI images (I have to specify the path to the .SEN3 folder rather than the .xml), I cannot open Sentinel 2 images / geotif / JP2 (SPOT).
Snap desktop opens the files without a problem. But in python (2.7), I get the following error:

RuntimeError: java.lang.IncompatibleClassChangeError: Implementing class

Any idea how to get around the problem or do I have to roll back to SNAP 5?

Max


#2

Hi Max,

can you enable the debug mode and send the logging information, please?

I’ve explained it earlier:

Then you should get much more output. Maybe too much :wink:
Put the last part containing the error in a text file and attach it, please.

Thanks


#3

Hi Marco,

Ok, I’ve put the log for a successful run (S3) and a failed run (S2) (edit: added output for a DEM in tiff format). See attached file, there isn’t that much output :slight_smile: .

Script LOG.txt (1.4 KB)


#4

I get a lot of these messages when I enable the debug logging:

JType_ProcessMethod: methodName="getXOrigin", paramCount=0, isStatic=0, mid=0000000026CF4900
JPy_FromTypeName: classRef=000000001A709700, jTypeNameChars="int"
JType_GetType: javaName="int", found=1, resolve=0, resolved=1, type=00000000039E4558
JType_ProcessReturnType: type->javaName="int", type=00000000039E4558
JType_ProcessMethod: methodName="getKernelData", paramCount=1, isStatic=0, mid=0000000026CF4908
JPy_FromTypeName: classRef=000000001A709840, jTypeNameChars="[D"
JType_GetType: javaName="[D", found=1, resolve=0, resolved=0, type=0000000003B491E8
JPy_FromTypeName: classRef=000000001A709898, jTypeNameChars="[D"
JType_GetType: javaName="[D", found=1, resolve=0, resolved=0, type=0000000003B491E8
JType_ProcessReturnType: type->javaName="[D", type=0000000003B491E8
JType_ProcessMethod: methodName="getYOrigin", paramCount=0, isStatic=0, mid=0000000026CF4910
JPy_FromTypeName: classRef=000000001A708370, jTypeNameChars="int"
JType_GetType: javaName="int", found=1, resolve=0, resolved=1, type=00000000039E4558
JType_ProcessReturnType: type->javaName="int", type=00000000039E4558
JType_ProcessClassFields: fieldCount=6
JMethod_InvokeMethod: calling static Java method org.esa.snap.core.dataio.ProductIO#readProduct
JMethod_InvokeMethod: calling Java method org.esa.snap.core.datamodel.Product#getRasterDataNode
JMethod_InvokeMethod: calling static Java method org.esa.snap.core.util.ProductUtils#copySpectralBandProperties
JMethod_InvokeMethod: calling Java method org.esa.snap.core.datamodel.Product#addBand
JMethod_InvokeMethod: calling static Java method org.esa.snap.core.dataio.ProductIO#writeProduct

In the last logs I don’t see the IncompatibleClassChangeError anymore. Is this problem solved?

Can you show the code of your sn_ops.open_product method? You raise the RuntimeError there. Probably when the result is None, right?
What puzzles me too is that you can only open S3 data by the directory. Actually, both should work. The directory and the xfdumanifest.xml file.


#5

I tried a different approach: I was running the script from inside an IDE (spyder). When I run the script from the terminal, I can open the S3 OLCI or SLSTR with the .xml file. I wonder if my internal Ipython interpreter wasn’t doing something funny. Anyway, that is the first step.

However, I still cannot open S2 images or geotiffs with my code. For S2, I still get:

INFO: org.esa.s2tbx.dataio.s2.ortho.S2OrthoProductReaderPlugIn: Building product reader - EPSG:32631
WARNING: org.esa.s2tbx.dataio.metadata.GenericXmlMetadata: Metadata: the path to element [metadata_level] does not exist
WARNING: org.esa.s2tbx.dataio.metadata.GenericXmlMetadata: Metadata: the path to element [granuleidentifier] does not exist
WARNING: org.esa.s2tbx.dataio.metadata.GenericXmlMetadata: Metadata: the path to element [bandid] does not exist
INFO: org.hsqldb.persist.Logger: dataFileCache open start

My function has nothing fancy, it is just:

def open_product(inpth):
‘’’ Read in a product using snappy’’’
try:
prod = ProductIO.readProduct(inpth)
except:
raise RuntimeError(‘Error: SNAP cannot read specified file!’)

return prod


Issues installing snappy Can't find SNAP distribution directory. Ubuntu 16.04 LTS
#6

This was something similar to what I got with SNAP 6.0 , before going back(for the moment) to SNAP 5.0


#7

It’s strange that it is not working.
I just let this script run and it worked create_filtered_band.py (1.7 KB)
I’ve used the SNAP 6 Preview5 and a Python 3.3

From the desktop everything is working?


#8

I’ve just run your script: same error as in my previous messages. I tried running it in my python 2.7 anaconda env, and in a python 3.4 environment. Neither work. Yet the desktop has no problems at all opening the products:


#9

Hi @maxlam64,

about the warnings on the S2 product, they are not actually a problem, we have some warnings depending on the PSD format of the product, but it should work properly with those warnings, perhaps we should remove them.

On the other hand, about the RuntimeError: java.lang.IncompatibleClassChangeError: Implementing class, once I had the same and fixed it by reconfiguring again snappy with snappy-conf and checking that I hadn’t an old snappy folder in my python environment.


#10

I tried 2 things:

  • reconfiguring snappy after having removed all the snappy folders in the virtual environement
  • creating a new environment and running all the steps in this post: How to install snappy

Still the RuntimeError… Could the problem be that I have multiple environments configured for snappy on my system? But then why does it work for S3 data?


#11

Try deleting the content of the .snap folder in the user dir. You’r on Mac, right?
On Windows you would need to delete the folder %appdata%\SNAP in addition.


#12

We are getting somewhere!

I deleted everything by removing the ‘.snap’ folder, running the uninstall script in ‘snap/bin’ and reinstalling Snap 6.

I can now open S3 and S2 images, as well as a DEM. :tada:

However, I get the following warnings (Are they important? Can I fix them? If not can I turn them off?):

INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters
SEVERE: org.esa.s2tbx.dataio.gdal.activator.GDALDistributionInstaller: The environment variable LD_LIBRARY_PATH does not contain the current folder ‘.’. Its value is ‘/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/’.

PS: At work, I’m not on Mac, but on a desktop Linux Debian


Urgent problem with snappy and snap 6.0
#13

Great news. :+1:
As far as I know, you can ignore the two messages.


#14

@marpet does this mean that with SNAP 6.0 we no longer need to have ~/.snap to read S2?


#15

No. The .snap folder is recreated if needed. But sometimes there can be garbage in this dir and then deleting it can help.