Hello,
I’m starting to get used of your very nice snappy from python.
Willing to get the viewing and solar angles values for each pixel I resample the S2 product. However, I cannot access the actual data afterward. Below is a example of my issue:
test_for_step_forum.py (1.1 KB)
import sys
import numpy as np
from snappy import ProductIO
from snappy import GPF
dir = ‘/DATA/Satellite/SENTINEL2/venice/L1C/’
file=dir+‘S2A_OPER_PRD_MSIL1C_PDMC_20160718T175711_R022_V20160718T101028_20160718T101028.SAFE/’
native product
product = ProductIO.readProduct(file)
sza=product.getBand(‘sun_zenith’)
width=sza.getRasterWidth()
szas2 = np.zeros(width, dtype=np.float32)
sza.readPixels(0, 0, width, 1, szas2)
print szas2
resampled product
GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis()
HashMap = jpy.get_type(‘java.util.HashMap’)
BandDescriptor = jpy.get_type(‘org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor’)
parameters = HashMap()
parameters.put(‘targetResolution’,60)
parameters.put(‘upsampling’,‘Bicubic’)
parameters.put(‘downsampling’,‘Mean’)
parameters.put(‘flagDownsampling’,‘FlagMedianAnd’)
parameters.put(‘resampleOnPyramidLevels’,True)
product=GPF.createProduct(‘Resample’, parameters, product)
sza=product.getBand(‘sun_zenith’)
width=sza.getRasterWidth()
szas2 = np.zeros(width, dtype=np.float32)
sza.readPixels(0, 0, width, 1, szas2)
print szas2
#which gives me
[ 28.1189003 28.09429932 28.06959915 28.04509926 28.02050018
27.99600029 27.97159958 27.94720078 27.92280006 27.89850044 27.8743
27.85009956 27.82589912 27.80179977 27.77770042 27.75370026
27.72970009 27.70569992 27.68180084 27.65800095 27.63419914
27.61050034]
[ nan nan nan …, nan nan nan]
Any idea to overcome this problem?
Thanks,
Tristan