Example script for multiple operations?

In python you don’t need the XML. here you can use the output of one operator as in input to the next operator.
You can start command line sub-processes to start the processing with gpt, or execute the graph directly as in the following snippet:

import snappy
from snappy import jpy, ProgressMonitor

FileReader = jpy.get_type('java.io.FileReader')
GraphIO = jpy.get_type('org.esa.snap.core.gpf.graph.GraphIO')
Graph = jpy.get_type('org.esa.snap.core.gpf.graph.Graph')
GraphProcessor = jpy.get_type('org.esa.snap.core.gpf.graph.GraphProcessor')

graphFile = FileReader('Path-to-graph-file.xml')
graph = GraphIO.read(graphFile)
GraphProcessor.executeGraph(graph, ProgressMonitor.NULL)

I haven’t tested this code snippet. it is a translation from the java code. But I guess it will work.

If you want to get more progress output you can have a look at this thread, on how to do it:

2 Likes