Overview of snappy functions?

Hi,
I’m kind of new to python, but I would like to work with snappy. We managed to install snappy and the test with the testcode was fine.
Is there anything anywhere which gives kind of an overview of the functions from snappy or something which compares the functions from snap, the desktop application, with snappy? I have the feeling that it is really difficult to start working with snappy, because I don’t know for sure what opportunities or functions I get with snappy.
I think I’m looking for something like a users how-to manual.

Unfortunately there’s no dedicated ‘How-to’ for the Python implementation, my best resource was http://step.esa.int/docs/v5.0/apidoc/engine/ which is for the Java SNAP Engine API, snappy wraps around this so it’s pretty handy to infer what a method will do.

Apart from that the forums are your friend!

Another useful tool was the gpt command line, it’s handy for gaining possible parameters to pass into the SNAP methods, especially when they don’t map quite perfectly to the Desktop ones!

Good luck!

3 Likes

Beside what is mentioned in the following post there are not many other manuals or examples.

On the tutorials page in the External Resources Category you find a link to some python examples. These will be extended in the future.
As snappy is just a wrapper around the SNAP Java API you can do almost everything what you can do in Java.
So you can also look at Java example code.

@marpet gave me a good example of getting parameters here

http://forum.step.esa.int/t/where-to-find-operator-parameters-for-snappy/4621/2?u=ciaranevans

Ok, thanks a lot.
I found the examples in the snappy directory and try to learn it that way. And I found the get -h command, which is very useful.

As @marpet said, in the external resources you can find the a link to a github repository with first basics tutorials about the usage of Snappy . From now on the repository will be quite regularly enriched with new tutorials that will deal with various functionalities of SNAP exploited in Python. As a little example the following RGB image has been obtained in Python as a result of a processing chain that resamples and extracted a subset of a full size Sentinel2 data product, with a contrast enhancing operation as the last step.

1 Like

Dear MaraM,

it took me some time to understand how to work with that. To save time for you and future users there are 2 ways:

  1. /bin/gpt -h Terrain-Correction or what ever operator you want.
  2. In python write this code and call it:
def get_snap_info(operator):
    """
    Returns information about SNAP operators and their parameters
    """
    op_spi = GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(operator)
    print('Op name:', op_spi.getOperatorDescriptor().getName())
    print('Op alias:', op_spi.getOperatorDescriptor().getAlias()) 
    param_Desc = op_spi.getOperatorDescriptor().getParameterDescriptors()
    for param in param_Desc:
          print(param.getName(), "or", param.getAlias())
get_snap_info(operator)

Hope that helps.

Cheers

4 Likes