Solar zenith angle

How can i export only solar zenith angle of sentinel-2 from SNAP…

Did you check up These posts, view angles

Source of the post

Source of the post

Source of the post

Source of the post

I am facing a similar need. At the moment I am using the following script through snappy:

import sys
sys.path.append('/path/to/esa-snap')
from snappy import jpy, ProductIO
import snappy

def s2_resampler(product, resolution=10, upmethod='Bilinear', downmethod='Mean', flag='FlagMedianAnd', opt=False):
    res = str(resolution)
    resampler = jpy.get_type('org.esa.s2tbx.s2msi.resampler.S2ResamplingOp')
    op = resampler()
    op.setParameter('targetResolution', res)
    op.setParameter('upsampling', upmethod)
    op.setParameter('downsampling', downmethod)
    op.setParameter('flagDownsampling', flag)
    op.setParameter('resampleOnPyramidLevels', opt)
    op.setSourceProduct(product)

    return op.getTargetProduct()


def main():
    product = ProductIO.readProduct('/path/to/S2.SAFE/')
    p_s2tbx = s2_resampler(product)
    band_names = p_s2tbx.getBandNames()
    print("Bands:   %s" % (list(band_names)))

    w, h = product.getSceneRasterWidth(),product.getSceneRasterHeight()
    
    sza = 'sun_zenith'
    product_sza = snappy.Product('sun_zenith_angle', p_s2tbx.getProductType(), w, h)
    snappy.ProductUtils.copyGeoCoding(product, product_sza)
    snappy.ProductUtils.copyBand(sza, p_s2tbx, sza, product_sza, True)
    ProductIO.writeProduct(product_sza, '/path/to/output/filename',  'GeoTIFF')