Hi,
I just updated to Snap10 and from Python 3.6 to 3.10 running on Windows 11, and it seems to have unleased lots of issues which I’m trying to work through.
I have an existing codebase that has been running happily for several years, opening S2 A and B products, resampling, zooming, pulling out band data etc…
Firstly the basic install worked fine and I can open some products using esa_snappy so no fundamental issue with setup.
But all of the most recent S2B_MSIL2A products throw this error:
Error reading product: java.io.IOException: Unable to read metadata from MTD_MSIL2A.xml
(this is actually what caused me to upgrade, as all the new products coming in started failing)
Older products still open, but when I try and resample and resize I am now getting this error: (there could be more issues but that is where my script crashes)
Exception has occurred: RuntimeError
org.esa.snap.core.gpf.OperatorException: Operator ‘ResamplingOp’: Value for ‘Target height’ must be of type ‘Integer’.
with this code:
targetWidth = int(targetWidth)
targetHeight = int(targetHeight)
parameters.put(‘targetWidth’, targetWidth)
parameters.put(‘targetHeight’, targetHeight)
resampled = GPF.createProduct(‘Resample’, parameters, product)
targetWidth and Height are 800,800, so definitely integers.
I’m not sure if something in this interface has changed or what, but I can replicate both of these issue in a simply python test file.
Any help would be greatly appreciated:
Python test code pasted below:
import sys
import numpy as np
import esa_snappy
from esa_snappy import ProductIO, HashMap, GPF
def resize(product, targetWidth, targetHeight):
parameters = HashMap()
parameters.put('targetWidth', targetWidth)
parameters.put('targetHeight', targetHeight)
resampled = GPF.createProduct('Resample', parameters, product)
print("Resized image to {} by {}".format(targetWidth, targetHeight))
return resampled
file = "c:/code/aquaspatial/py/S2A_MSIL2A_20180112T021911_N0500_R060_T50HMJ_20230802T065254.zip"
# this one fails to open - comment in
#file = "c:/code/aquaspatial/py/S2B_MSIL2A_20240724T223709_N0511_R072_T59GLL_20240725T020713.zip"
product = None
try:
product = ProductIO.readProduct(file)
except Exception as e:
print("Error reading product: ", e)
sys.exit(1)
if product is None:
print("Product is None")
sys.exit(1)
bands = product.getBandNames()
for band in bands:
print(band)
# try a resize
zoomedIn = resize(product, 800,800)