Snap 13: BatchProcessing Graph Builder unusable, were is the path of writing files, how to work around the BUG

Dear Snap users,

The new interface of SNAP 13 , of Batch Processing, Graph Buider, has no longer the option save as or Directory

This is causing that the outputs are being over written for every scene in this case by Biophysical10mOp.geotiff

The expected behavious would be:

  • Biophysical10mOp_1
  • Biophysical10mOp_2
  • Biophysical10mOp_N

Is there a workaround to this issue?

Many thanks for any help you may provide,
Joseph

Dear Joseph,

After loading the list of products, go to the Write operator and fill the Name field with the value “target”, then click on Run.

myGraph.xml (1.5 KB)

A great thanks for your kindness in helping with Batch Processing. The proposed solution did not work, so I programmed a code in Julia language to perform the different steps which works I am sharring the code.

The code:

One of the concern of my code is in the .xml file is to automatically derive the

      <pixelRegion>0,0,10980,10980</pixelRegion>

JULIA CODE TO BATCH PROCESS

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#		FUNCTION : RUN_SNAP
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	""" SNAP_LAI_FAPAR_NDVI_FVC

		OUTPUT:

			Derives batch processing from sentinel data by using SNAP modules:
			* Mask to the area of interest
			* Lai,
			* FAPAR,
			* NDVI,
			* FVC

		INPUT:
			* PathInput: path of all the .zip file of the .SAFE sentinel data
			* PathOutput: path of the output of Lai, FAPAR, NDVI, FVC
			* PathShapeFile: path of the shape file were the delimitation of the catchment
			* PathXml: path of the .xml file derived from SNAP software
			* PathProperties: this is a temporary path
	"""
	function SNAP_BATCH_LAI_FAPAR_NDVI_FVC(;PathInput, PathOutput, PathShapeFile, PathXml, PathProperties, NameOutput_Lai="LAI",NameOutput_Fapar="FAPAR",NameOutput_Ndvi="NDVI", NameOutput_Fvc="FVC")

      AllSentinelData = readdir(PathInput)
      AllSentinelData = sort!(AllSentinelData)

		# For every scene
	 for iiSentinelData ∈ AllSentinelData

			# Deriving dates from sentinel file name
            iFind        = findfirst("_", iiSentinelData)
            DateSentinel = iiSentinelData[iFind[1]+1:end]
            iFind        = findfirst("_", DateSentinel)
            DateSentinel = DateSentinel[iFind[1]+1:end]

            Year_Scene   = parse(Int64, DateSentinel[1:4])
            Month_Scene  = parse(Int64, DateSentinel[5:6])
            Day_Scene    = parse(Int64, DateSentinel[7:8])
            Hour_Scene   = parse(Int64, DateSentinel[10:11])
            DateFormat   = Year_Scene * 10000 + Month_Scene * 100 + Day_Scene

			# Paths of output
            NameOutput_Lai₁   = string(DateFormat) * "_" * NameOutput_Lai * ".tif"
            PathOutput_Lai₁   = joinpath(PathOutput, NameOutput_Lai₁)

            NameOutput_Fapar₁ = string(DateFormat) * "_" * NameOutput_Fapar * ".tif"
            PathOutput_Fapar₁ = joinpath(PathOutput, NameOutput_Fapar₁)

            NameOutput_Ndvi₁  = string(DateFormat) * "_" * NameOutput_Ndvi * ".tif"
            PathOutput_Ndvi₁  = joinpath(PathOutput, NameOutput_Ndvi₁)

            NameOutput_Fvc₁   = string(DateFormat) * "_" * NameOutput_Fvc * ".tif"
            PathOutput_Fvc₁   = joinpath(PathOutput, NameOutput_Fvc₁)

            PathInput₁        = joinpath(PathInput, iiSentinelData)

            PathProperties₁   = joinpath(PathProperties, "Parameters_" * string(DateFormat) * ".properties")

			# Saving the paths into .properties so gpt software can pick it up
				open(PathProperties₁,"w") do io
					println(io, "PathInput =  $PathInput₁")
					println(io, "PathOutput_Lai =  $PathOutput_Lai₁" )
					println(io, "PathOutput_Ndvi = $PathOutput_Ndvi₁" )
					println(io, "PathOutput_Fvc = $PathOutput_Fvc₁")
					println(io, "PathOutput_Fapar = $PathOutput_Fapar₁")
					println(io, "PathShapeFile =  $PathShapeFile")
				end

			# Run the command line
				try
					RunSnap = `gpt $PathXml -e -p $PathProperties₁`
					run(RunSnap)
					printstyled("	======================= SUCESSFULL= $iiSentinelData =================== \n", color=:green  )
				catch
					printstyled("	======================= NOT SUCESSFULL= $iiSentinelData =================== \n", color=:red  )
				end

			# The .properties is no longer needed
				rm(PathProperties₁)

		end # for iiSentinelData ∈ AllSentinelData
	end # function RUN_SNAP()
	# ------------------------------------------------------------------

Automatically generate .properties file

where $ is your defined path which the code generates automatically

PathInput =  $PathInput
PathOutput_Lai =  $PathOutput_Lai
PathOutput_Ndvi = $PathOutput_Ndvi
PathOutput_Fvc = $PathOutput_Fvc
PathOutput_Fapar = $PathOutput_Fapar
PathShapeFile =  $PathShapeFile

.xml file

<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>${PathInput}</file>
      <copyMetadata>true</copyMetadata>
      <bandNames/>
      <pixelRegion>0,0,10980,10980</pixelRegion>
      <maskNames/>
    </parameters>
  </node>
  <node id="Import-Vector">
    <operator>Import-Vector</operator>
    <sources>
      <sourceProduct refid="Read"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <vectorFile>${PathShapeFile}</vectorFile>
      <separateShapes>false</separateShapes>
    </parameters>
  </node>
  <node id="Land-Sea-Mask">
    <operator>Land-Sea-Mask</operator>
    <sources>
      <sourceProduct refid="Resample"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <sourceBands>B1,B2,B3,B4,B5,B6,B7,B8,B8A,B9,B11,B12,quality_aot,quality_wvp,quality_cloud_confidence,quality_snow_confidence,quality_scene_classification,B_detector_footprint_B1,B_detector_footprint_B2,B_detector_footprint_B3,B_detector_footprint_B4,B_detector_footprint_B5,B_detector_footprint_B6,B_detector_footprint_B7,B_detector_footprint_B8,B_detector_footprint_B8A,B_detector_footprint_B9,B_detector_footprint_B11,B_detector_footprint_B12,B_ancillary_lost_B1,B_ancillary_degraded_B1,B_msi_lost_B1,B_msi_degraded_B1,B_defective_B1,B_nodata_B1,B_partially_corrected_crosstalk_B1,B_saturated_l1a_B1,B_ancillary_lost_B2,B_ancillary_degraded_B2,B_msi_lost_B2,B_msi_degraded_B2,B_defective_B2,B_nodata_B2,B_partially_corrected_crosstalk_B2,B_saturated_l1a_B2,B_ancillary_lost_B3,B_ancillary_degraded_B3,B_msi_lost_B3,B_msi_degraded_B3,B_defective_B3,B_nodata_B3,B_partially_corrected_crosstalk_B3,B_saturated_l1a_B3,B_ancillary_lost_B4,B_ancillary_degraded_B4,B_msi_lost_B4,B_msi_degraded_B4,B_defective_B4,B_nodata_B4,B_partially_corrected_crosstalk_B4,B_saturated_l1a_B4,B_ancillary_lost_B5,B_ancillary_degraded_B5,B_msi_lost_B5,B_msi_degraded_B5,B_defective_B5,B_nodata_B5,B_partially_corrected_crosstalk_B5,B_saturated_l1a_B5,B_ancillary_lost_B6,B_ancillary_degraded_B6,B_msi_lost_B6,B_msi_degraded_B6,B_defective_B6,B_nodata_B6,B_partially_corrected_crosstalk_B6,B_saturated_l1a_B6,B_ancillary_lost_B7,B_ancillary_degraded_B7,B_msi_lost_B7,B_msi_degraded_B7,B_defective_B7,B_nodata_B7,B_partially_corrected_crosstalk_B7,B_saturated_l1a_B7,B_ancillary_lost_B8,B_ancillary_degraded_B8,B_msi_lost_B8,B_msi_degraded_B8,B_defective_B8,B_nodata_B8,B_partially_corrected_crosstalk_B8,B_saturated_l1a_B8,B_ancillary_lost_B8A,B_ancillary_degraded_B8A,B_msi_lost_B8A,B_msi_degraded_B8A,B_defective_B8A,B_nodata_B8A,B_partially_corrected_crosstalk_B8A,B_saturated_l1a_B8A,B_ancillary_lost_B9,B_ancillary_degraded_B9,B_msi_lost_B9,B_msi_degraded_B9,B_defective_B9,B_nodata_B9,B_partially_corrected_crosstalk_B9,B_saturated_l1a_B9,B_ancillary_lost_B11,B_ancillary_degraded_B11,B_msi_lost_B11,B_msi_degraded_B11,B_defective_B11,B_nodata_B11,B_partially_corrected_crosstalk_B11,B_saturated_l1a_B11,B_ancillary_lost_B12,B_ancillary_degraded_B12,B_msi_lost_B12,B_msi_degraded_B12,B_defective_B12,B_nodata_B12,B_partially_corrected_crosstalk_B12,B_saturated_l1a_B12,B_opaque_clouds,B_cirrus_clouds,B_snow_and_ice_areas,view_zenith_mean,view_azimuth_mean,sun_zenith,sun_azimuth,view_zenith_B1,view_azimuth_B1,view_zenith_B2,view_azimuth_B2,view_zenith_B3,view_azimuth_B3,view_zenith_B4,view_azimuth_B4,view_zenith_B5,view_azimuth_B5,view_zenith_B6,view_azimuth_B6,view_zenith_B7,view_azimuth_B7,view_zenith_B8,view_azimuth_B8,view_zenith_B8A,view_azimuth_B8A,view_zenith_B9,view_azimuth_B9,view_zenith_B10,view_azimuth_B10,view_zenith_B11,view_azimuth_B11,view_zenith_B12,view_azimuth_B12</sourceBands>
      <landMask>false</landMask>
      <useSRTM>false</useSRTM>
      <geometry>TimoleagueBoundaries</geometry>
      <invertGeometry>false</invertGeometry>
      <shorelineExtension>0</shorelineExtension>
    </parameters>
  </node>
  <node id="Resample">
    <operator>Resample</operator>
    <sources>
      <sourceProduct refid="Import-Vector"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <referenceBand/>
      <targetWidth/>
      <targetHeight/>
      <targetResolution>10</targetResolution>
      <upsampling>Bilinear</upsampling>
      <downsampling>First</downsampling>
      <flagDownsampling>First</flagDownsampling>
      <resamplingPreset/>
      <bandResamplings/>
      <resampleOnPyramidLevels>false</resampleOnPyramidLevels>
    </parameters>
  </node>
  <node id="Biophysical10mOp">
    <operator>Biophysical10mOp</operator>
    <sources>
      <sourceProduct refid="Land-Sea-Mask"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <sensor>S2A_10m</sensor>
      <computeLAI>true</computeLAI>
      <computeFapar>false</computeFapar>
      <computeFcover>false</computeFcover>
    </parameters>
  </node>
  <node id="Biophysical10mOp(2)">
    <operator>Biophysical10mOp</operator>
    <sources>
      <sourceProduct refid="Land-Sea-Mask"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <sensor>S2A_10m</sensor>
      <computeLAI>false</computeLAI>
      <computeFapar>true</computeFapar>
      <computeFcover>false</computeFcover>
    </parameters>
  </node>
  <node id="Write(2)">
    <operator>Write</operator>
    <sources>
      <sourceProduct refid="Biophysical10mOp(2)"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>${PathOutput_Fapar}</file>
      <formatName>GeoTIFF-BigTIFF</formatName>
    </parameters>
  </node>
  <node id="Biophysical10mOp(3)">
    <operator>Biophysical10mOp</operator>
    <sources>
      <sourceProduct refid="Land-Sea-Mask"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <sensor>S2A_10m</sensor>
      <computeLAI>false</computeLAI>
      <computeFapar>false</computeFapar>
      <computeFcover>true</computeFcover>
    </parameters>
  </node>
  <node id="Write(3)">
    <operator>Write</operator>
    <sources>
      <sourceProduct refid="Biophysical10mOp(3)"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>${PathOutput_Fvc}</file>
      <formatName>GeoTIFF-BigTIFF</formatName>
    </parameters>
  </node>
  <node id="NdviOp">
    <operator>NdviOp</operator>
    <sources>
      <sourceProduct refid="Land-Sea-Mask"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <resampleType>None</resampleType>
      <upsampling>Nearest</upsampling>
      <downsampling>First</downsampling>
      <redFactor>1.0</redFactor>
      <nirFactor>1.0</nirFactor>
      <redSourceBand>B4</redSourceBand>
      <nirSourceBand>B8</nirSourceBand>
    </parameters>
  </node>
  <node id="Write(4)">
    <operator>Write</operator>
    <sources>
      <sourceProduct refid="NdviOp"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>${PathOutput_Ndvi}</file>
      <formatName>GeoTIFF-BigTIFF</formatName>
    </parameters>
  </node>
  <node id="Write">
    <operator>Write</operator>
    <sources>
      <sourceProduct refid="Biophysical10mOp"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
		<file>${PathOutput_Lai}</file>
      <formatName>GeoTIFF-BigTIFF</formatName>
    </parameters>
  </node>
</graph>

Graph

With kindness,
Joseph A.P. Pollacco