Snappy vs SNAP GUI S2Resampling difference

Hello,
I am using the snappy module to automate the processing of S2 L1C and L2A images to extract single bands. These are my processing steps which I have successfully implemented in python: S2Resampling>Subset>Write to Geotiff.
My issue is that the overlapping pixel values of the Geotiffs processed using SNAP GUI and snappy module are not similar. The difference in file size is also significant (6.5MB and 45MB while using snappy and SNAP GUI respectively).
Below is part of my code where I am performing the Resampling and Subsetting steps. I have tried forcing the default S2Resampling parameters but I still can’t get similar results.

#Resample Products
def resampling(product, resampleSize):
    paramsResample = HashMap()
    paramsResample.put('resolution', resampleSize)
    paramsResample.put('downsampling', 'Mean')
    paramsResample.put('upsampling', 'Bilinear')
    paramsResample.put('flagDownsampling', 'First')
    paramsResample.put('sampleOnPyramidLevels', 'true')
    productResampled = GPF.createProduct('S2Resampling', paramsResample, product)
    return productResampled
  
#Subset and write to Geotiff
def subset(resampledProduct, band, fname):
    paramsSubset = HashMap()
    paramsSubset.put('sourceBands', band)
    productResampledSubset = GPF.createProduct('Subset', paramsSubset, resampledProduct)
    print('Saving raster to:\t'+ str(os.path.join(out_dir, fname)))
    ProductIO.writeProduct(productResampledSubset, os.path.join(out_dir, fname), 'GeoTIFF', pm)
    return productResampledSubset

Thanks

1 Like