Reading Sentinel 2 pixel data with snappy


Hi! I’m new to python and snappy. I am trying to read all bands (not just B01) of a Sentinel 2 image and create a dictionary containing all the information (to be able to call, for example, B01 and see the array of pixel values). The final goal is to convert the dictionary into a netcdf file format. Any help will be appreciated!

Here is what I got so far:

import sys, os

import snappy
from snappy import ProductIO
p1 = ProductIO.readProduct(“T16QEJ_20180914T160901_B01.jp2”)


First, you should use the full path with the readProduct method.
os.chdir does not work. It only works in the Python environment and with snappy you are using Java.

Also, you should use the MTD_MSIL1C.xml file and not the jp2 file. This way, the product which is returned by readProduct will contain all bands.