How to use Read operator with S2 L1C data?

I would like to realise a script for GPT, which reads a S2 L1C image and extract certain bands over a certain area of interest.
If I operate through the GUI, I perform:
a) subset providing bands and geographical area bounding box
b) export

So I built a GPT xml script with the following operators:

  1. Read
  2. Subset (with settings taken from previous bullet a)
  3. Write

Every time I launch the script I have an error: “Error: org/esa/snap/framework/datamodel/GeoCoding”

Then I tried with:

  1. Read
  2. BandMath simply copying the needed bands
  3. Reproject including my area of interest
  4. Write

I’ve then the same error. This is the log with the -e command:

java.lang.NoClassDefFoundError: org/esa/snap/framework/datamodel/GeoCoding
at org.esa.s2tbx.dataio.s2.ortho.S2OrthoProduct60MReaderPlugIn.createReaderInstance(S2OrthoProduct60MReaderPlugIn.java:44)
at org.esa.snap.core.dataio.ProductIO.getProductReaderForInput(ProductIO.java:277)
at org.esa.snap.core.gpf.common.ReadOp.initialize(ReadOp.java:88)
at org.esa.snap.core.gpf.internal.OperatorContext.initializeOperator(OperatorContext.java:499)
at org.esa.snap.core.gpf.internal.OperatorContext.getTargetProduct(OperatorContext.java:278)
at org.esa.snap.core.gpf.Operator.getTargetProduct(Operator.java:359)
at org.esa.snap.core.gpf.graph.NodeContext.initTargetProduct(NodeContext.java:74)
at org.esa.snap.core.gpf.graph.GraphContext.initNodeContext(GraphContext.java:195)
at org.esa.snap.core.gpf.graph.GraphContext.initNodeContext(GraphContext.java:178)
at org.esa.snap.core.gpf.graph.GraphContext.initNodeContext(GraphContext.java:178)
at org.esa.snap.core.gpf.graph.GraphContext.initOutput(GraphContext.java:162)
at org.esa.snap.core.gpf.graph.GraphContext.(GraphContext.java:91)
at org.esa.snap.core.gpf.graph.GraphContext.(GraphContext.java:64)
at org.esa.snap.core.gpf.graph.GraphProcessor.executeGraph(GraphProcessor.java:130)
at org.esa.snap.core.gpf.main.DefaultCommandLineContext.executeGraph(DefaultCommandLineContext.java:84)
at org.esa.snap.core.gpf.main.CommandLineTool.executeGraph(CommandLineTool.java:502)
at org.esa.snap.core.gpf.main.CommandLineTool.runGraph(CommandLineTool.java:350)
at org.esa.snap.core.gpf.main.CommandLineTool.runGraphOrOperator(CommandLineTool.java:249)
at org.esa.snap.core.gpf.main.CommandLineTool.run(CommandLineTool.java:150)
at org.esa.snap.core.gpf.main.CommandLineTool.run(CommandLineTool.java:122)
at org.esa.snap.core.gpf.main.GPT.run(GPT.java:54)
at org.esa.snap.core.gpf.main.GPT.main(GPT.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.esa.snap.runtime.Launcher.lambda$run$12(Launcher.java:55)
at org.esa.snap.runtime.Engine.runClientCode(Engine.java:186)
at org.esa.snap.runtime.Launcher.run(Launcher.java:51)
at org.esa.snap.runtime.Launcher.main(Launcher.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:62)
at com.exe4j.runtime.WinLauncher.main(WinLauncher.java:101)
at com.install4j.runtime.launcher.WinLauncher.main(WinLauncher.java:16)
Caused by: java.lang.ClassNotFoundException: org.esa.snap.framework.datamodel.GeoCoding
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
… 37 more

Error: org/esa/snap/framework/datamodel/GeoCoding

Then, just to make a test, I removed the Reproject step 3, leaving only the band math. Again the same error occurs.

Finally I tried to build the last one (with only bandmath) on the Graph Builder and noticed that if I configure the Read module to read the image in native resolution the graph builder gives a warning and SNAP become unusable untill I close the Graph Builder. If I select one resolution it works.
Maybe there is a parameter for the Read module to ask for a specific resolution?

Regards

Hi,

probably you still have a beta version installed of SNAP and the Sentinel-2 Toolbox.
Uninstall the current version and try reinstalling the latest version and get afterwards the latest module updates. Please ensure during installation that the SNAP-internal configuration data and also the SNAP user data checkboxes are marked.

Thank you Marco for you fast answer.
Even if it seems that all modules and plugins were updated, I uninstalled and then reinstalled SNAP 2.0 with the S2 Toolbox and now the error about GeoCoding was gone.

However I still had some issues about the Read operator: from my tests I understood that it opens a S2 L1C image as “Native resolutions” (like when opening it via GUI) and this limits the number of tools that can be applied (“Error: Product ‘S2A_OPER_MTD_SAFL1C_PDMC_20151225T192348_R079_V20151225T100538_20151225T100538’ has raster of different sizes and can not be processed.”)

Then I tried with the Graph Builder and saw that Read operator has an option for selecting how to open the S2 L1C image. It is translated - within the xml - with the setting of the “formatName” parameter as “SENTINEL-2-MSI-10M-UTM33N”.
With this parameter set all works fine, however it is a parameter dependent on the S2 L1C scene. I suppose that if the scene is outside UTM33N, then that formatName would be no more valid.

Is that correct? Is (or will be) the formatName parameter of the Read operator documented somewhere?

Giulio

Yes it is correct, sadly this is currently our only solution to handle the complexity of S2 products, which can provide data in several distincts UTM zones.

In GPT you need to specify the formatName. Otherwise you are opening with a random reader.
There is no good default choice, as products can have tiles in different UTM zones.