Export the TOA reflectance of 1c product to CSV file

Dear all.

I am trying to export the TOA reflectance value of 1C product to a CSV file. I do it in SNAP but it didn’t work.
do someone have any ideas or other solutions?


At which step you are stuck in SNAP?

Otherwise, pixel export is usually done with GIS software (QGis, Arcgis) with extract to table tools or python/C with GDAL.

1 Like

Dear Guillaume,

I open a 1c product by SNAP. Then I click 1 band,for example, band 1,then click on File,choose export to CSV. The output CSV has only a line containing the number of pixels of this band image while I need the value( the reflectance value) of each pixel in this image.

In another hand, as you say, when exporting the image by GIS software to CSV file, how does the CSV file look like?

In this case, I think it would be profitable if you explain your final goal.

For the whole image as asked :
raster menu>Data conversion>convert datatype. There choose CSV and in parameter, I assume that float32 or int32 is better than int8 for you.

For a few points extraction :
Using SNAP, in raster menu>Export>Extract Pixels Values. But there you will need to enter all the coordinates you want an extraction.

For simple statistics use gdalinfo.

Assuming you want complex statistics on those pixels, may I suggest you to export your product to *tif file (same procedure as for the CSV). Then go on R + raster module. Import the image with stack() and change it to vector with getValues().

CSV style with Arcgis :

Thank Guillaume,

My idea is that:

  • firstly, I download the 1c product of Sentinel 2 from Peps.This product contains several tiles,each tiles has 13 band images
  • secondly, I would like to apply the scene classification algorithm to each tiles. This helps me to know a pixel is a snow,cloud or vegetation,…). This algorithm needs the reflectance value of each pixel to perform.
    And, I am trying to export these value to csv files.
  • I tried exporting the whole image as you said above, but it didn’t work. The SNAP error " Product xxx has raster of different sizes and cannot be processed"
  • exporting a few points with extract coordinates seems to be not good way for my case.
  • exporting the whole image to tif file leads to the same error as CSV.
    I also use openJPEG to convert image to tif file. But, I found some changes of value of pixel between the orginal image and new tif image


My exporting with SNAP proposition apparently need to take into account bands pixel size…

So lets do it with graph builder : just open the graph builder, directly link read and write operators. Choose write parameter for a CSV file. All bands are going to be resampled at 10m (huge file).

Hint : if you do not need all bands, modify the < sourcebands > in the saved graph XML file, and keep the bands of interest.

For classification, you want it on tiles or on image? Both are possible… and with many software, using TIF or JP2 (Arcgis is reading JP2, you can directly visualize each tile/granule and apply a classification there).

Otherwise, use GDAL (above 1.11.2) to convert jp2 to TIF (be aware of HDD space needed).

Dear Guillaume
With graph builder, I set Read to the whole 1C product and set Write to CSV file. An error “unhandled file type” pop up. SNAP also cannot read dicrectly a jp2 file.

I think I will try with Arcgis.
Thank for your help.


Well open the entire product if you want to do this process chain (using
the S2_***.xml in the .SAFE folder).

I know, SNAP apparently can open the whole product via *.xml. But, SNAP cannot open jp2 while it can open other types as BMP and Tiff.

If it bothers you, then go for a direct opening via Arcgis. It will open
JP2, you can classify or export them directly from there.

1 Like

SNAP can actually open jp2 files directly.

1 Like

Dear Nicolas,

It is quite a good new for me. Can you show me how? It didn’t work with me

File/Open product and select the jp2 file you want to import, or
File/Import/Generic formats/JPEG-2000 and select your file

Did you get an error message?

yes, the both way leads to the same error message: “error while reading file”.
I opened jp2 file of a tile in the whole product.
I only can open the whole product or the whole tile (by clicking on xml file), but not a separated jp2 file.


What version of SNAP are you using and under what OS?
Could you send us the message.log file? Under Windows it is under the user home directory under the path AppData\Roaming\SNAP\var\log, under Linux it is under ~/.snap/system/var/log
Thanks in advance.

Dear Nicolas.

My version is 2.0.2 for Windows 10.
You can see log file and error message when i open jp2 file.
messages.log (164.9 KB)

Thank for your help.

I can reproduce your problem with your version of SNAP and recent products but it will be fixed in the next release that should come in a few days, I think it is related to this JIRA issue: https://senbox.atlassian.net/browse/SIITBX-189 (see the comment)

Thank Nicolas.

The comment mentioned that “This was true for the first products, but then it changed.This is corrected for version 3.0”
This means I can read jp2 file by version 1?


No, it means it will be fixed in SNAP/S2TBX 3.0 which will be released very soon… With SNAP/S2TBX 2.0.2 you can read JPEG 2000 files of older product but not the recent ones.

THank Nicolas.

Just one more question

Do you know what the “dl” unit in the image above means?