Beginner Questions

I am a complete beginner. I have only worked with MATLAB and Python in Windows in the past but more for developing my own scripts than actual software development. My current work assesses the possibility of developing customized tools for SNAP (most important would be a classification algorithm). For now I am trying to understand SNAP development and currently examining s2-rut.

  1. I got s2-rut and packaged it to a .nbm file. When I install it, it appears on Optical->Preprocessing. Before I delve in to the code, is it right to assume that the GUI is automatically generated (based from the template of I/O and Processing Tabs from most of the algorithms in SNAP)? Where do you specify which Menu it goes and other details like that?

  2. Why is s2-rut not included in Tools -> Manage External Tools but sen2cor is? This is also true in GraphBuilder where sen2cor is available as an operator. Is this why the sen2cor data is very different as s2-rut? There is no .pom file for it to be packaged with maven. What are the essential differences? They seem similar in that they simply take I/O and processing info and output a file.

  3. What are the differences of a toolbox, plugin, operator etc? Are operators simply scripts that can be called by plugins or by GraphBuilder, and if so, are they like gui-less plugins? What is an Adapter Suite?

  4. What are the differences/advantages of making a plugin than creating a custom operator? I am currently of the opinion that it is better to just develop custom operators, package it in a graph for later use in Batch Processing than creating a single plugin for each of your steps.

Sorry I know that a lot of these are basic but if you guys could at least point out resources. I am currently reading the Cookbook but it’s still fuzzy at the moment. Thank you in advance.

If you found the Cookbook already you have the most information at hand. However, I’ll give you some brief answers to your question.

  1. Yes, the GUI is created automatically based on the information provided in s2_rut-info.xml. Where the processor shows up in the menu is defined in the layer.xml (see How to write a processor in Python).

  2. S2Rut is not in “Manage External Tools” because it is not an external tool. External tools are 3rd party applications and are stand-alone tools. It is possible to provide adapters for such application to make them usable with SNAP. These adapters are managed and configured by “Manage External Tools”. So the difference is that sen2cor is an application on it’s on, integrated into SNAP by an adapter. S2rut is a plugin for SNAP. Right now I don’t know why the s2-rut tool is not showing up in the GraphBuilder. It could be that it is not compatible with the Builder. Not all operators can be used in the graph builder. This is an issue which will be addressed in the future.

  3. I List some of the terms here, you will come across when developing for and with SNAP.
    Toolbox - This is an assembly of several modules. It gets also a special tab in the about dialog.
    Module - A single module; can comprise several plugins and processors and operators
    Processor - A processor is mainly made up by an operator, but Help pages, auxiliary data, etc. belongs to it too
    Plugin - A plugin extends SNAP in some way. This can be an operator, a product reader or a product writer. Or a tool window for SNAP Desktop.
    Operator - Strictly speaking, this simply implements the Operator interface. This is were the processing of a processor takes place.

  4. There is no plugin vs. operator. If you want to provide an operator you need to provide it as plugin. And you can’t package an operator into a graph. It can be used within a graph.

An additional note. Currently, the Python interface for implementing an operator has several limitations and I would suggest to implement you segmentation algorithm in Java. Usually Java is also faster than Python.
The limitations of Python will be addressed in the future, but I can’t give a schedule.

Thank you very much for the answers, it clarified my confusion regarding the various terms and their uses (esp. #4).

As a follow-up, can you please correct/comment on my understanding of the contents of snap-examples:

  • snap-engine-python-scripts - This example shows how to use Snap engine API classes in a python script thru the snappy module. Why does this have a pom though? Can I build this with maven? How will it function as an installable .nbm file if it’s only a script (or I’m terribly uninformed of the usage of pom).

  • snap-engine-python-operator - This is a complete operator. layer.xml defines where it goes in Snap, -info.xml defines the gui and the intended parameters. defines the operator class and invokes snappy to pull parameters as described (obtained?) from -info.xml and passes it to variables readable by the actual algorithm implementing script that is Well described here. You’ve said that this is an implementation of an operator. Does this mean that the actual operator is similar to snap-engine-python-scripts instead?

  • snap-engine-java-operator - Same as above, but the equivalent, -info.xml, and is condensed to one file. Which makes sense since Snap’s “native” API is a Java API.

  • snap-engine-otb-python-operator - This apparently uses the Orfeo toolbox module. The calculation is done in the file itself. Is this considered an imported computational Java module? Although it still uses numpy, so like a hybrid? Like Jython?

  • snap-jython-examples - Some Jython examples. It seems that Jython is used for more intricate operations (like the Spectral Unmixing tool perhaps?) instead of scripting simple algorithms.

For the above examples, I think I already have a slight understanding, but I don’t know how these other examples relate to them:

  • snap-desktop-basic-multi
  • snap-desktop-basic-single
  • snap-desktop-examples
  • snap-engine-examples

Are they directly built to Snap? Like an add-on to a custom Snap installation?

I am currently making progress in studying snap-engine-python-operator and s2-rut to get a better handle (hopefully I can transition to java later but I’ll stick to python for now) on how to develop my own plugin. Thank you again.

In this case the pom is useless. You are right. It is just there because the other projects have it too.

No the actual operator is implemented in Java and the Python implementation is called by this operator. See PyOperator on GitHub

Yes, it just demonstrates that you can use OTB and Python to provide functionality for SNAP.

Honestly we didn’t do more then these examples with Jython. And I think no one else did. But it shows that it is possible to integrate your own actions into the menu.

snap-desktop-basic-multi and snap-desktop-basic-single are just template projects. You can use them to set up your own project.

snap-desktop-examples and snap-engine-examples contain sample code which you can use for your own implementation. They are just implemented with dummy functionality. But they show how things can be done.

I recommend that you implement you operator in Java, if you can. The Python way has still some limitations and it is slower too.