I resolved one part of the problem with the idea presented in this post OLCI C2RCC bulk processing - s3tbx - STEP Forum (esa.int). Now the problem it is that with a *.dim file the gpt won’t start, but the same process will start with a *.SAFE file…
Below I’ll describe and write the whole process.
THIS IS THE WINDOWS BATCH
::@echo off
:: enable delayed expansion - used to resolve variable in loop
:: variable has to be used with '!' instead of '%'
setlocal ENABLEDELAYEDEXPANSION
::::::::::::::::::::::::::::::::::::::::::::
:: User Configuration
::::::::::::::::::::::::::::::::::::::::::::
:: adapt this path to your needs
set gptPath="C:\Program Files\snap\bin\gpt.exe"
::::::::::::::::::::::::::::::::::::::::::::
:: Command line handling
::::::::::::::::::::::::::::::::::::::::::::
:: first parameter is a path to the graph xml
set graphXmlPath=%1
:: use third parameter for path to source products
set sourceDirectory=%2
:: if sourceDirectory ends with '\' remove it
if %sourceDirectory:~-1%==\ set sourceDirectory=%sourceDirectory:~0,-1%
:: use third parameter for path to source products
set sourceDirectory2=%3
:: if sourceDirectory ends with '\' remove it
if %sourceDirectory2:~-1%==\ set sourceDirectory=%sourceDirectory2:~0,-1%
:: use third parameter for path to target products
set targetDirectory=%4
:: if targetDirectory ends with '\' remove it
if %targetDirectory:~-1%==\ set targetDirectory=%targetDirectory:~0,-1%
set targetFilePrefix=L1C_IDEP_
:: Create the target directory
::md %targetDirectory%
::::::::::::::::::::::::::::::::::::::::::::
:: Main processing
::::::::::::::::::::::::::::::::::::::::::::
:: double '%' in batch file and only a single '%' on command line
:: '/D' is for directories like Sentinel data. Remove '/D' when you open files.
for /D /R %sourceDirectory% %%F in (S2*.SAFE) do (
for /D /R %sourceDirectory2% %%N in (*.dim) do (
echo
:: '~fF' means abolute path of 'F'
set sourceFile=%%~fF
set sourceFile2=%%~fN
echo sourceFile2=%sourceDirectory2%\%%~fN
echo Processing !sourceFile!
:: '~nF' means filename without extension of 'F'
set targetFile=%targetDirectory%\%targetFilePrefix%%%~nF.dim
set procCmd=%gptPath% %graphXmlPath% -e -t "!targetFile!" "!sourceFile!" "!sourceFile2!"
call !procCmd!
))
HERE IS THE .XML GRAPH FOR MERGING BANDS FROM DIFFERENT PRODUCTS AND ALSO RESAMPLE THE NEW PRODUCT IN THE END
<graph id="Graph">
<version>1.0</version>
<node id="mergeNode">
<operator>Merge</operator>
<sources>
<masterProduct>${sourceProduct1}</masterProduct>
<level2>${sourceProduct2}</level2>
</sources>
<parameters>
<includes>
<include>
<productId>masterProduct</productId>
<name>B1</name>
<newName>B1</newName>
</include>
<include>
<productId>masterProduct</productId>
<name>B2</name>
<newName>B2</newName>
</include>
<include>
<productId>level2</productId>
<name>B7</name>
<newName>B7</newName>
</include>
</includes>
</parameters>
</node>
<node id="Resample">
<operator>Resample</operator>
<sources>
<sourceProduct refid="mergeNode"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<referenceBand/>
<targetWidth/>
<targetHeight/>
<targetResolution>10</targetResolution>
<upsampling>Nearest</upsampling>
<downsampling>First</downsampling>
<flagDownsampling>First</flagDownsampling>
<resamplingPreset/>
<bandResamplings/>
<resampleOnPyramidLevels>true</resampleOnPyramidLevels>
</parameters>
</node>
</graph>
THE FINAL BATCH COMMAND TO CREATE A MERGED AND RESAMPLED PRODUCT
PATH_TO_BATCH_FILE\gpt_S2_merge.bat PATH_TO_MERGE_GRAPH\graph_merge_test_inverse.xml PATH_TO_FIRST_PRODUCT\S2L2A_brute
PATH_TO_SECOND_PRODUCT\S2_Idepix
PATH_TO_RESULTED_PRODUCT\S2_final\test
This whole workflow works with to .SAFE files in the configuration batch but not with a .SAFE and .DIM file. Anyone knows what the problem might be?