Process SNAP graphs with CWL
The described method targets processing Earth Observation data with the SNAP Graph Processing Tool (GPT) using docker and CWL.
CWL is used to invoke the SNAP gpt
command line tool and deals with all the docker volume mounts required to process a Graph and EO data available on the host.
The examples rely on a simple SNAP graph applying the Calibration
operator to a Sentinel-1 GRD acquisition:
<graph id="Graph">
<version>1.0</version>
<node id="Read">
<operator>Read</operator>
<sources/>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<file>${inFile}</file>
<formatName>SENTINEL-1</formatName>
</parameters>
</node>
<node id="Calibration">
<operator>Calibration</operator>
<sources>
<sourceProduct refid="Read"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
<auxFile>Product Auxiliary File</auxFile>
<externalAuxFile/>
<outputImageInComplex>false</outputImageInComplex>
<outputImageScaleInDb>false</outputImageScaleInDb>
<createGammaBand>false</createGammaBand>
<createBetaBand>false</createBetaBand>
<selectedPolarisations>${selPol}</selectedPolarisations>
<outputSigmaBand>true</outputSigmaBand>
<outputGammaBand>false</outputGammaBand>
<outputBetaBand>false</outputBetaBand>
</parameters>
</node>
<node id="Write">
<operator>Write</operator>
<sources>
<sourceProduct refid="Calibration"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<file>./cal.dim</file>
<formatName>BEAM-DIMAP</formatName>
</parameters>
</node>
</graph>
This SNAP graph contains parameters:
${inFile}
is the path to the Sentinel-1manifest.xml
file. This parameter is used in theRead
Operator${selPol}
is the selected polarization and thus leaving an option to processVV
orVH
(typically). This parameter is used in theCalibration
Operator
CWL is used to wrap the SNAP gpt
executable:
gpt sar-calibration.xml -PselPol=${selPol} -PinFile=${inFile}
There are two approaches described to process this graph using CWL:
- The SNAP graph is a local file and thus passed to CWL as a File (as a reference)
- The SNAP graph XML content is part of the CWL (included as a value)