SNAP Graph builder universal band select

I am using SNAP to process multiple files from command line by iterating through all the files in a folder. I ran into a problem when using “Multilooking” or “BandMath” and I need to select specific bands. Previously with other graphs I have built the graphs in SNAP with example files and changed the input and output string to a variable.

But how do I universally select a parameter. At the moment in the graph the source bands are <sourceBands>i_VV_24Aug2015_17Sep2015,q_VV_24Aug2015_17Sep2015</sourceBands> , from the example files, but how to I change the source band so that it would work with other files as well. I want to use i and q bands, which are the first and second band.

Can this be solved by using sourceBandPaths? How do I use it?

<node id="GoldsteinPhaseFiltering"> <operator>GoldsteinPhaseFiltering</operator> <sources> <sourceProduct refid="TopoPhaseRemoval"/> </sources> <parameters class="com.bc.ceres.binding.dom.XppDomElement"> <alpha>1.0</alpha> <FFTSizeString>64</FFTSizeString> <windowSizeString>3</windowSizeString> <useCoherenceMask>false</useCoherenceMask> <coherenceThreshold>0.2</coherenceThreshold> </parameters> </node> <node id="Multilook"> <operator>Multilook</operator> <sources> <sourceProduct refid="GoldsteinPhaseFiltering"/> </sources> <parameters class="com.bc.ceres.binding.dom.XppDomElement"> <sourceBands>i_VV_24Aug2015_17Sep2015,q_VV_24Aug2015_17Sep2015</sourceBands> <nRgLooks>10</nRgLooks> <nAzLooks>2</nAzLooks> <outputIntensity>false</outputIntensity> <grSquarePixel>false</grSquarePixel> </parameters> </node> <node id="BandMaths"> <operator>BandMaths</operator> <sources> <sourceProduct refid="Multilook"/> </sources> <parameters class="com.bc.ceres.binding.dom.XppDomElement"> <targetBands> <targetBand> <name>phase</name> <type>float32</type> <expression>phase(i_VV_24Aug2015_17Sep2015,q_VV_24Aug2015_17Sep2015)</expression> <description/> <unit/> <noDataValue>NaN</noDataValue> </targetBand> </targetBands> <variables/> </parameters> </node>

You can introduce a variable too.
Maybe just for the time span or the list of band names.
In the attached example I introduced a ${timeSpan} variable. From the command line, you can set this variable as follows

gpt graph.xml -PtimeSpan=24Aug2015_17Sep2015 ...

For each call, you just need to change this parameter.

useOfVariable.xml (1.7 KB)

3 Likes

Has anyone found a better way of solving this?

I am asking since the code I have needs to write a geotiff containing only the phase band from a interferogram.dim which includes other bands such as coherence and intensity using snappy.
The problem is that the band naming scheme is pretty elaborate and it is rather annoying to code for this since different polarisations / dates in the ddMmmyyyy format is used for the band name.

I imagine one way would be to inpsect the metadata for all the bands and then glob to find the ifg band? Or maybe the interferogram wil always be the first band so it’s index in a band list can be used? How would I get a list of all bands in the product?

Thank you