Use a derived band math variable in second band math operator

I have a SAR product from which I use Sigma_HH, Sigma_HV and Sigma_VV [output from Speckle-filter], on which I apply a band math operation to derive a transformed variable (lets call it X). [This step works fine]
Then I want to use X with one of the original variables, e.g., Sigma_HH, to derive e.g. X*Sigma_HH.
[This step fails with the error "Expression is invalid. Undefined symbol ‘X’ "]

How can I access both the original and derived variables within a graph? I also elaborated on landing the outputs in BandMerge first, but yet without success.

I use SNAP 8.08 on Win 10.


please remove this link (re-create the graph if necessary) and check if the bands appear


Thanks for your reply Andreas. I should have written, that none of the input bands to the BandMath operator were forwarded to the second without adding the second link (the one you proposed to remove). That was the reason that I added this, since I needed these bands together with the output of BandMath for my second BandMath operator.

Side-note: The Graph Builder appears a little bit buggy to me and sometimes complains that it does not find the input bands from Speckle-Filter (e.g., Sigma0_HH), e.g. after removing BandMaths(2). Editing the xml directly and edit the Source name or remove and re-add the ‘failing’ module usually fixes it, but it can be challenging to figure out which module that is causing the error. Clearer error messages would be a much appreciated improvement to future versions of the Graph Builder.

Anyways, I wonder if the name format somehow changes when using two sources in a module? E.g. if I add two sources (Speckle-filter and the output from BandMath) to the LinearToFromdB, I can see the following names of the available bands (variable name, double colon, and the filename):

However, I would like to access the variable names without locking them to the file that I currently process.

1 Like

I see, thank you for explaining. Maybe someone has an idea…

Bandmaths can be used to compare two files processed with different versions of a program. The graph reads two files and uses the same bandname from different files, so filenames are useful to identify the two data sets.

Can your calculation be rewritten to use one more complex bandmath expression?

For batch processing you could use the xml graph with gtp in a shell script that supplies the input filenames.

Thank you @gnwiii for your reply. Yes, in my particular case I could rewrite it as a single bandmath operator as work-around. Nevertheless, my curiosity wanted to understand the principle also for more complex situations :slight_smile: The option to write the intermediate results to files and then process it a second round through gpt also works as work-around, although it would be preferred within a single graph.

I agree that Band Maths is not suitable for complex operations. There are many well-designed and supported languages (Java, Python (or Python-based GIS like QGIS), Matlab, IDL, etc.) that can be used. Adding user-generated bands to BEAM DIMAP or NetCDF format is not difficult (NASA Ocean Color processing moved to NetCDF4-CF, but many tools use an external product.xml file to provide metadata – each new product requires an entry in the product.xml file).