How to apply user defined operation on multiple cropped sentinel-2 images using gpt script?

I’m quite new to SNAP and I have an issue regarding gpt.
How to apply user defined operation on multiple cropped sentinel 2 images using gpt script?
Here is the process:

  1. I have ~200 sentinel-2 images (.zip files).
  2. I cropped each one of them using gpt Subset script (=area of interest). And got .dim and .data files for each image.
  3. I want to apply an operation on each of the cropped images (.dim files) that is not included in the gpt operations (=my operation is: Biological Crust Index = 1 - (RED-BLUE)/(RED+BLUE) ).
    For this I used band-math and saved the xml file named “CrustIndex.xml”.
  4. I want to apply this new operation=CrustIndex.xml in a gpt script that will go through all ~200 sentinel-2 cropped images (.dim files). How can I do it? What should I change in the “CrustIndex.xml” file?

*** Here is the relevant part in my script which is not working yet (f=the cropped .dim file, target=t=.tif file):
./gpt CrustIndex.xml -Pfile=<dollar_sign>f -t <dollar_sign>{DIR}/${name}.tif

*** What should I write in the CrustIndex.xml file between the of the “read” and “write” part?


Hello rickysh,

How you can do batch processing is explained on this wiki page:
Bulk Processing with GPT - SNAP Wiki
You can use the BandMath op to define your operation

I attach an example of a graph using BandMaths: band_math_s2.xml (1.3 KB)