Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

An Operator is a class that may operate on data from a number of source data products and create a new data product as a result. An Operator can be used within the SNAP Graph Processing Framework (GPF). The GPF provides a fast and efficient way to execute operators, as computation is performed tile-wise: The grid that is spun up by the target product is divided into evenly spaced spatial subsets, called tiles. The size of the tile may be dependent on the requests of other Operators in the graph. The tiles are computed separately and simultaneously.

A tile is a chunk of data. The full scene image is not processed at once, as this would lead to a lot of memory problems. So we split the data into rectangular tiles and process each tile individually. Multiple times may be processed simultaneously. You are requested to fill the target tile rectangle with data, but you are free to access any source data also outside of the target rectangle. Where you get the data from is up to you.

A GPF Operator extends the abstract class Operator. When you extend the Operator class, there are five methods that you must or may implement:

  • void initialize(): This method is called before any actual computing is performed. Its purpose is to validate the input parameters and source products. It is also responsible for creating the target product and its properties. It is the only method that is not optional to be implemented.

  • void computeTile(Tile targetTile, ProgressMonitor pm): This method is expected to compute and set values for a tile of a single band of the target product. The implementation of this method is optional. If it is implemented, computeTileStack should not be implemented.

  • void computeTileStack(Map<Band, Tile> targetTiles, Rectangle targetTileRectangle, ProgressMonitor pm): This method is expected to compute and set values for tiles of multiple bands of the target product. If it is implemented, computeTile should not be implemented,

  • void doExecute(ProgressMonitor pm): This method is optional. It may be used for time-consuming tasks that need to be conducted before the actual computation takes place or to actually do all the processing instead of computeTile() and computeTileStack().

  • void dispose(): This method is called after the target product has been computed. By implementing it you may release any resources the operator has been using to free cache.

To get a better understanding which methods you need to implement, look at Operator Implementation Guidelines .

Project Structure

Create a module with a file structure as

Code Block
my-module/
    src/main/
        java/<code-base>/*.java
        javahelp/*
        nbm/manifest.mf
        resources/META-INF/services/org.esa.snap.core.gpf.OperatorSpi
        resources/helpset.xml
        resources/layer.xml
    src/test/
        java/<code-base>/*.java
        resources/<code-base>/*
pom.xml

For convenience, you can clone the module from the template processor operator. Your Java Code should be based in my-module/src/main/java/<code-base>/, there you should place your Operator sub-class. Tests should be placed in my-module/src/test/java/<code-base>/, test resources in my-module/src/test/resources/<code-base>/. The meaning of the other files is explained in How to integrate an operator .

Defining Operator Metadata

...