I have downloaded several Sentinel 2 images using the Microsoft Planetary Computer Python API and have come across many transparent/corrupted pixels in these images. These pixels appear mainly when downloading the TCI band (“visual” band) of Sentinel 2, other bands (green, blue,…) don’t seem to have such a problem. I don’t know if the problem is how I load the data and transform the file, if it is due to cloud-optimized GeoTIFF (COG) data or problems in Microsoft image generation.
import pystac import planetary_computer import rioxarray item_url = "https://planetarycomputer.microsoft.com/api/stac/v1/collections/sentinel-2-l2a/items/S2B_MSIL2A_20230111T121649_R066_T27PTS_20230112T034530" item = pystac.Item.from_file(item_url) signed_item = planetary_computer.sign(item) ds = rioxarray.open_rasterio( signed_item.assets["visual"].href).squeeze() ds.rio.to_raster("exampleVisual.tif")
If this file is opened with QGIS or the SNAP program of that one, the following is observed:
The original TCI image is obtained from Copernicus (S2B_MSIL2A_20230111T121649_N0509_R066_T27PTS_20230111T141317)
In the code, the normal geoTIFF is generated from the COG downloaded from Planetary, if you directly download the .tiff file (in COG format) from the link indicated in
signed_item.assets["visual"].href, you still see those errors with slight modifications.
As you can see in the images, there are pixels with very low luminosity that become transparent. I would like to know if someone has an explanation or solution to this phenomenon.