Band maths from two input products with snappy

Hi there,

I am trying to write a short script to do band maths using bands from two products (same dimensions) like one can do using the GUI - is there an easy way to do this?

Many thanks,
Ludo

Sorry to be persistent with this - has anybody been able to find a way to do this? If so could you please tell me?

Thanks again,
Ludo

have you seen this thread?

Yes, however it is not immediately obvious to me how to put two bands from two different input products into the expression - is this done using the HashMap operator_

alright, I just wanted to give a hint. But if you are already beyond that - we need to wait for someone with knowledge on snappy.

Hi Ibuizza,

You are right, it is not obvious how to do it. So let me give you some pointers how to achieve this.
In the directory of the snappy examples is one examples which shows how to use BandMaths on one product. Here is the code on GitHub

If you want to use multiple source products you can follow the example given in this post:

Here the Merge operator is used but providing multiple products works the same.

  1. Create a HashMap and map the products to some names
  2. Pass this map to the call of GPF.createProduct()
  3. In the expressions, you can use the given names to differentiate between the products.
    Using the names in the post you can do e.g. $masterProduct.band_1 and $slaveProduct.band_1

I hope this helps.

Hi all,

Thanks again for your help - what I´ve done is do what you have suggested and merge my two products (thankfully the bands in question have different names) and then do the band maths from one single product.

Ludo