S2 bulk processing

Wondering if anyone has a script/code (Graph Builder) to bulk/batch process Sentinel-2 images? Basically I want to add a folder with several S2 Level 1C images and want to:

Platform - Windows 10 64-bit

  1. Convert with Sen2Cor to surface reflectance
  2. Extract bands (NIR)
  3. Layer stack
  4. Calculate some indices (NDVI, NDWI, etc.)
  5. Export all above images in GeoTIFF (Big TIFF)

Thanks in advance.

1 Like

You should do the first step separately. When having the L2A data you can either use the Graph Builder on the new data set or write the graph on your own.
These wiki pages might help:
https://senbox.atlassian.net/wiki/spaces/SNAP/pages/70503590/Creating+a+GPF+Graph
https://senbox.atlassian.net/wiki/spaces/SNAP/pages/70503475/Bulk+Processing+with+GPT

1 Like

Thanks @marpet.
@ouceda posted this code that I’m guessing process all S2 L1C input files to L2A at 10 m resolution:
for /D %s in (C:\Teledete\Diciembre\S2MSIL1C) do L2AProcess %s --resolution=10
Is it possible to specify output as tiff in the above code?
Would it be possible for you to share a sample of the above workflow that I can try and tweak? I think it’ll be really helpful for lot of us :slight_smile:

As far as I know, sen2cor can’t generate GeoTiff files. You will need to convert them afterwards.

Hi. I am novice to SNAP, so sorry for my (probably) stupid question. I have a bunch of products which I need to export as geotif, just selected bands within them. Using the graph creator I would like to create an xml that reads the product, selects a band within it, and exports it as geotif. At the moment I can’t figure out if there is a tool in the graph builder that allows exporting the images as geotif. Did I miss it? Is there a workaround that makes me avoid doing it manually? Thank you in advance.

you can use the Band Select operator (under Data Conversion in the graph menu) followed by the writer where you select GeoTiff as output.

1 Like

Great! It works. Thanks a lot.

Hi,
I have been tryong to run sen2cor from command line to process several L1C images with this code you gave, but everytime I press enter it appears an error “too few arguments” and then nothing happens.

I would reallly appreciate if you could give me any insight to what I am doing wrong, since I do not have many experience using the cmd.

This is the message and the lines I am trying to use:

C:\Users\samen\Desktop\Sen2Cor-02.08.00-win64>for /D %s in (F:\1\S2A_MSIL1C*) do L2A_Process.bat --resolution=10

C:\Users\samen\Desktop\Sen2Cor-02.08.00-win64>L2A_Process.bat --resolution=10
usage: L2A_Process.py [-h] [–mode MODE] [–resolution {10,20,60}]
[–datastrip DATASTRIP] [–tile TILE]
[–output_dir OUTPUT_DIR] [–work_dir WORK_DIR]
[–img_database_dir IMG_DATABASE_DIR]
[–res_database_dir RES_DATABASE_DIR]
[–processing_centre PROCESSING_CENTRE]
[–archiving_centre ARCHIVING_CENTRE]
[–processing_baseline PROCESSING_BASELINE] [–raw]
[–tif] [–sc_only] [–cr_only] [–debug]
[–GIP_L2A GIP_L2A] [–GIP_L2A_SC GIP_L2A_SC]
[–GIP_L2A_AC GIP_L2A_AC] [–GIP_L2A_PB GIP_L2A_PB]
input_dir
L2A_Process.py: error: too few arguments