E' possibile utilizzare SNAP in modalita' headless installando da remoto su un server il normale pacchetto di SNAP. A seconda del fatto che sia presente o meno una sessione di interfaccia grafica o meno viene eseguito un tipo diverso di installer
Per eseguire una catena di comandi in SNAP si puo' in maniera interattiva creare un grafico con Graph Builder e salvare il grafico in formato xml
questo e' un esempio di grafico salvato da SNAP per il calcolo NDVI tramite BandMath
=============================================================
<graph id="Graph">
<version>1.0</version>
<node id="Read">
<operator>Read</operator>
<sources/>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<useAdvancedOptions>false</useAdvancedOptions>
<file>/home/luca/transi/S2B_MSIL2A_20220811T100559_N0400_R022_T32TPP_20220811T162101.zip</file>
<copyMetadata>true</copyMetadata>
<bandNames/>
<pixelRegion>0,0,10980,10980</pixelRegion>
<maskNames/>
</parameters>
</node>
<node id="BandMaths">
<operator>BandMaths</operator>
<sources>
<sourceProduct refid="Read"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<targetBands>
<targetBand>
<name>NDVI</name>
<type>float32</type>
<expression>(B8 - B4) / (B8 + B4)</expression>
<description/>
<unit/>
<noDataValue>0.0</noDataValue>
</targetBand>
</targetBands>
<variables/>
</parameters>
</node>
<node id="Write">
<operator>Write</operator>
<sources>
<sourceProduct refid="BandMaths"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<file>/home/luca/transi/BandMath.tif</file>
<formatName>GeoTIFF</formatName>
</parameters>
</node>
<applicationData id="Presentation">
<Description/>
<node id="Read">
<displayPosition x="37.0" y="134.0"/>
</node>
<node id="BandMaths">
<displayPosition x="184.0" y="136.0"/>
</node>
<node id="Write">
<displayPosition x="455.0" y="135.0"/>
</node>
</applicationData>
</graph>
=============================================================
per renderlo utilizzabile in modalita' batch si devono modificarlo per inserire delle variabili
Le variabili sono nel formato ${nome_variabile}
Nel codice sottostante e' stato reso variabile il file di input
=============================================================
<graph id="Graph">
<version>1.0</version>
<node id="Read">
<operator>Read</operator>
<sources/>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<useAdvancedOptions>false</useAdvancedOptions>
<file>${ingresso}</file>
<copyMetadata>true</copyMetadata>
<bandNames/>
<pixelRegion>0,0,10980,10980</pixelRegion>
<maskNames/>
</parameters>
</node>
<node id="BandMaths">
<operator>BandMaths</operator>
<sources>
<sourceProduct refid="Read"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<targetBands>
<targetBand>
<name>NDVI</name>
<type>float32</type>
<expression>(B8 - B4) / (B8 + B4)</expression>
<description/>
<unit/>
<noDataValue>0.0</noDataValue>
</targetBand>
</targetBands>
<variables/>
</parameters>
</node>
<node id="Write">
<operator>Write</operator>
<sources>
<sourceProduct refid="BandMaths"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<file>/home/luca/transi/ndvi.tif</file>
<formatName>GeoTIFF</formatName>
</parameters>
</node>
<applicationData id="Presentation">
<Description/>
<node id="Read">
<displayPosition x="37.0" y="134.0"/>
</node>
<node id="BandMaths">
<displayPosition x="184.0" y="136.0"/>
</node>
<node id="Write">
<displayPosition x="455.0" y="135.0"/>
</node>
</applicationData>
</graph>
=============================================================
da linea di comando si puo' usare lo switch -P per popolare la variabile
-Pnome_variabile=valore_variabile
per lanciare il processo per esempio si puo' usare
/home/luca/snap/bin/gpt ndvi2.xml -Pingresso=/home/luca/transi/S2B_MSIL2A_20220811T100559_N0400_R022_T32TPP_20220811T162101.zip