Hi,
I am new with the snappy API. I would like to implement a python script capable of generating Sentinel2 view azimuth angle (VZA) band.
At the moment I am using the following script:
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()
band = 'B4'
vaa='view_azimuth_'+band
product_vaa = snappy.Product('view_azimuth_angle', p_s2tbx.getProductType(), w, h)
snappy.ProductUtils.copyGeoCoding(product, product_vaa)
snappy.ProductUtils.copyBand(vaa, p_s2tbx, vaa, product_vaa, True)
ProductIO.writeProduct(product_vaa, '/path/to/output/filename', 'GeoTIFF')
However, s2_resampler, performs the resampling in the entire product. Since I need only the VZA resampled, is there a way to improve this calculation and not perform the resampling on all bands or to generate only the VZA band?