thank you for your quick reply. Your answers in previous threads were very useful to me. I was able to find a workaround for the issue in the post and now the basic test code is working as follows.
import os
# Set the environment variables
os.environ['JAVA_HOME'] = '/Library/Java/JavaVirtualMachines/microsoft-11.jdk/Contents/Home'
os.environ['SNAP_HOME'] = '/Applications/esa-snap'
# Verifying the variables
print("JAVA_HOME:", os.environ.get('JAVA_HOME'))
print("SNAP_HOME:", os.environ.get('SNAP_HOME'))
import sys
sys.path.append('/Users/User/.snap/snap-python') # esa_snappy directory
from esa_snappy import ProductIO,GPF
p = ProductIO.readProduct('/Users/User/.snap/snap-python/esa_snappy/testdata/MER_FRS_L1B_SUBSET.dim')
print(list(p.getBandNames()))
After verifying I can import esa_snappy, I wanted to write a basic script that converts .tiff file to .png.
Here is the code that I tried:
# Path to .tiff file
tiff_file = '/Users/PATHTOFILE/S1A_IW_GRDH_1SDV_20240822T032941_20240822T033015_055320_06BECC_2CDD_COG.SAFE/measurement/s1a-iw-grd-vv-20240822t032941-20240822t033015-055320-06becc-001-cog.tiff'
# Load the .tiff file as a product using esa_snappy
product = ProductIO.readProduct(tiff_file)
Output:
RuntimeError Traceback (most recent call last)
Cell In[160], line 8
5 tiff_file = '/Users/PATHTOFILE/TASK_1/S1A_IW_GRDH_1SDV_20240822T032941_20240822T033015_055320_06BECC_2CDD_COG.SAFE/measurement/s1a-iw-grd-vv-20240822t032941-20240822t033015-055320-06becc-001-cog.tiff'
7 # Load the .tiff file as a product using esa_snappy
----> 8 product = ProductIO.readProduct(tiff_file)
RuntimeError: java.lang.NoClassDefFoundError: Could not initialize class org.esa.snap.dataio.gdal.reader.GDALProductReader
I also tried verifying that I can view .tiff files on the SNAP software but the software didn’t allow me. I’d be grateful if you can assist me with this.
good to hear that you could solve your original problem with the hints which were given in this forum.
However, your new problem does not seem to be related to esa_snappy. As you say that you cannot even open that tif file with SNAP desktop, it sounds like a problem in the SNAP core modules. Thus I suggest that you also report the issue in the more general part of the forum, e.g. here. Apart from that I’ll ask colleagues if they might know about the problem.
I located the GDAL folder in the directory you mentioned, and after deleting it, I was able to successfully view the TIFF file using the SNAP software. However, I noticed that the GDAL folder reappears after running SNAP.Here arethe contents of the gdal folder for your reference
The gdal folder is recreated by SNAP if it does not exist. Sometimes it can happen that its content becomes corrupted, and for this reason, it needs to be deleted.
If I understood correctly, you are able to open TIFF files with SNAP, but not from your python script.
Could you remove these to lines and try again? export GDAL_DATA=“/opt/homebrew/share/gdal” export GDAL_LIBRARY_PATH=“/opt/homebrew/lib”
Hello dolaf,
I had the same issue similar to hassanql, But I could not the path [home directory]/.snap/system/var/log folder.
There is no system folder in .snap path:
the user hassanql is/was working on a MacOS platform. On Mac and Linux machines, the log folder is located as given above, whereas on Windows it is located at
[home directory]/.snap/var/log, or at
[home directory]/AppData/Roaming/SNAP/var/log
I will add a clarification in the esa_snappy documentation. - However, apart from that it seems that this is not the right thread for that gdal/tiff issue (?), which is not related to esa_snappy.
Thank you for the response @dolaf. I want to import esa_snappy to process sentinel -1 GRD data.
I installed SNAP version 10. python version 3.10
I am using windows. I have checked the paths provided here, but I could not see SNAP in any of them either.
your screenshots indicate that your SNAP installation is somewhat incomplete/corrupt. Could you ever run SNAP desktop successfully? What is the content of your SNAP installation directory (E:\SNAP_File_env\esa-snap)? The ‘snap’ subfolder in your 3rd image should contain more subfolders (not just ‘modules’) as well as many jar files. Did you try to configure esa_snappy as described in the documentation?
I suggest that you uninstall SNAP (or its fragments) and re-install, running the SNAP installer for Windows again.