S3 LST reproject with SNAP gpt not working

Hello,

I am trying to reproject S3 LST data to a fixed latitude/longitude grid.

The gpt command I am running over a test ROI of 1° x 1° is

/usr/local/snap/bin/gpt "./s3_preproc.xml" -p "./s3_preproc.prop" -Pinfile="./S3A_SL_2_LST____20220301T100410_20220301T100710_20220302T172506_0179_082_279_0720_LN2_O_NT_004.SEN3" -Pout_geom="./S3A-LN2-SL-2-LST_20220301T100410_GEOM.tif" -Pout_mask=".S3A-LN2-SL-2-LST_20220301T100410_MSK.tif" -Pout_lst="./S3A-LN2-SL-2-LST_20220301T100410_LST.tif" -Pepsg="EPSG:4326" -Peasting=4.0 -Pnorthing=51.0 -Ds3tbx.reader.slstr.pixelGeoCoding=true

With the following prop file:

epsg=EPSG:4326
refPxX=0.5
refPxY=0.5
pxSizeX=0.00892857142857
pxSizeY=0.00892857142857
windowSizeX=112
windowSizeY=112

The xml is:

<graph id="Graph">
  <version>1.0</version>
  <!-- infile doesn't have to be de manifest.xml file, the root directory
       in which that files resides is sufficient -->
  <node id="Read">
    <operator>Read</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>${infile}</file>
    </parameters>
  </node>
  <!-- select bands to speed up reproject step -->
  <node id="BandSelect_LST">
    <operator>BandSelect</operator>
    <sources>
      <sourceProduct refid="Read"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <selectedPolarisations/>
      <sourceBands>LST,LST_uncertainty,confidence_in,bayes_in</sourceBands>
      <bandNamePattern/>
    </parameters>
  </node>
  <!-- Reproject to fix pxSize and window size -->
  <node id="Reproject">
    <operator>Reproject</operator>
    <sources>
      <sourceProduct refid="BandSelect_LST"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <wktFile/>
      <crs>${epsg}</crs>
      <resampling>Bilinear</resampling>
      <referencePixelX>${refPxX}</referencePixelX>
      <referencePixelY>${refPxY}</referencePixelY>
      <easting>${easting}</easting>
      <northing>${northing}</northing>
      <orientation>0.0</orientation>
      <pixelSizeX>${pxSizeX}</pixelSizeX>
      <pixelSizeY>${pxSizeY}</pixelSizeY>
      <width>${windowSizeX}</width>
      <height>${windowSizeY}</height>
      <tileSizeX/>
      <tileSizeY/>
      <orthorectify>false</orthorectify>
      <elevationModelName/>
      <noDataValue>NaN</noDataValue>
      <includeTiePointGrids>true</includeTiePointGrids>
      <addDeltaBands>false</addDeltaBands>
    </parameters>
  </node>
  <!-- Save LST to disk -->
  <node id="Subset_LST">
    <operator>Subset</operator>
    <sources>
      <source>Reproject</source>
    </sources>
    <parameters>
        <sourceBands>LST,LST_uncertainty</sourceBands>
      <copyMetadata>true</copyMetadata>
    </parameters>
  </node>
  <node id="Write_LST">
    <operator>Write</operator>
    <sources>
      <sourceProduct refid="Subset_LST"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>${out_lst}</file>
      <formatName>GeoTIFF</formatName>
    </parameters>
  </node>
  <!-- Save geometry to disk -->
  <node id="Subset_GEOM">
    <operator>Subset</operator>
    <sources>
      <source>Reproject</source>
    </sources>
    <parameters>
        <sourceBands>sat_zenith_tn,solar_zenith_tn,longitude_tx,latitude_tx</sourceBands>
        <tiePointGridNames>sat_zenith_tn,solar_zenith_tn,longitude_tx,latitude_tx</tiePointGridNames>
      <copyMetadata>true</copyMetadata>
    </parameters>
  </node>
  <node id="Write_Geometry">
    <operator>Write</operator>
    <sources>
      <sourceProduct refid="Subset_GEOM"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>${out_geom}</file>
      <formatName>GeoTIFF</formatName>
    </parameters>
  </node>
  <!-- Calculate mask and save to disk -->   
  <node id="BandMaths_mask">
    <operator>BandMaths</operator>
    <sources>
      <sourceProduct refid="Reproject"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <targetBands>
        <targetBand>
          <name>mask</name>
          <type>int8</type>
          <expression>if bayes_in&amp;2 == 2 OR confidence_in&amp;16384 == 16384 then 1 else 0</expression>
	  <noDataValue>-1</noDataValue>
          <description/>
          <unit/>
        </targetBand>
      </targetBands>
      <variables/>
    </parameters>
  </node>
  <node id="Write_mask">
    <operator>Write</operator>
    <sources>
      <sourceProduct refid="BandMaths_mask"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>${out_mask}</file>
      <formatName>GeoTIFF</formatName>
    </parameters>
  </node>
</graph>

The run fails with this message:

INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: GDAL 2.3.2 found on system. JNI driver will be used.
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Installed GDAL 2.3.2 set to be used by SNAP.
INFO: org.esa.snap.core.util.EngineVersionCheckActivator: Please check regularly for new updates for the best SNAP experience.
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Installed GDAL 2.3.2 set to be used by SNAP.
Executing processing graph
WARNING: org.esa.s3tbx.dataio.s3.AbstractProductFactory: ./S3A_SL_2_LST____20220301T100410_20220301T100710_20220302T172506_0179_082_279_0720_LN2_O_NT_004/S3A_SL_2_LST____20220301T100410_20220301T100710_20220302T172506_0179_082_279_0720_LN2_O_NT_004.SEN3 (Is a directory)
WARNING: org.esa.s3tbx.dataio.s3.AbstractProductFactory: Could not find ''.
INFO: org.hsqldb.persist.Logger: dataFileCache open start
 done.

Error: [NodeId: Subset_GEOM] Operator 'SubsetOp': Value for 'Tie-Point Grids' is invalid: 'sat_zenith_tn'

I am using SNAP 9.0.0.
Any idea what goes wrong here?
Thanks in advance!

Hi

after reprojection the tie-point grids are not tie-point grids anymore. They become bands.
you need to move “sat_zenith_tn,solar_zenith_tn,longitude_tx,latitude_tx” to the sourceBands tag.

It indeed works now, after removing the line with tiePointGridNames.
So this part in the xml becomes:

<node id="Subset_GEOM">
    <operator>Subset</operator>
    <sources>
      <source>Reproject</source>
    </sources>
    <parameters>
        <sourceBands>sat_zenith_tn,solar_zenith_tn,longitude_tx,latitude_tx</sourceBands>
      <copyMetadata>true</copyMetadata>
    </parameters>
  </node>

Thanks a lot for your swift reply!
Best regards,
Carolien

1 Like