Command-line automatic coregistration with gpt

Dear All,

I want to use the “Automatic Coregistration” within the command-line to register calibrated and range-doppler terrain corrected Sentinel-1A Scenes under Windows 7.

There are basically 5 steps:
ProductSet-Reader
CreateStack
GCP-Selection
Warp
Write

Using those commands with gpt always gives an error, probably because they should
be somehow connected.
I also created and checked an XML-File with the Desktop Application, but in the command line
the WriteOP gave an error.

Is there any way to make the Automatic Coregistration work in the command-line, preferably without XML??
Otherwise what is wrong with the XML-File (posted below) that worked in the Desktop Software but not
in the command-line?

Thanks in advance and best regards!

<graph id="Graph">
  <version>1.0</version>
  <node id="CreateStack">
    <operator>CreateStack</operator>
    <sources>
      <sourceProduct.2 refid="ProductSet-Reader"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <masterBands/>
      <sourceBands/>
      <resamplingType>NONE</resamplingType>
      <extent>Master</extent>
      <initialOffsetMethod>Orbit</initialOffsetMethod>
    </parameters>
  </node>
  <node id="GCP-Selection">
    <operator>GCP-Selection</operator>
    <sources>
      <sourceProduct refid="CreateStack"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <numGCPtoGenerate>200</numGCPtoGenerate>
      <coarseRegistrationWindowWidth>128</coarseRegistrationWindowWidth>
      <coarseRegistrationWindowHeight>128</coarseRegistrationWindowHeight>
      <rowInterpFactor>2</rowInterpFactor>
      <columnInterpFactor>2</columnInterpFactor>
      <maxIteration>10</maxIteration>
      <gcpTolerance>0.5</gcpTolerance>
      <applyFineRegistration>true</applyFineRegistration>
      <fineRegistrationWindowWidth>32</fineRegistrationWindowWidth>
      <fineRegistrationWindowHeight>32</fineRegistrationWindowHeight>
      <coherenceWindowSize>3</coherenceWindowSize>
      <coherenceThreshold>0.6</coherenceThreshold>
      <useSlidingWindow>false</useSlidingWindow>
      <computeOffset>false</computeOffset>
      <onlyGCPsOnLand>false</onlyGCPsOnLand>
    </parameters>
  </node>
  <node id="Warp">
    <operator>Warp</operator>
    <sources>
      <sourceProduct refid="GCP-Selection"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <rmsThreshold>0.5</rmsThreshold>
      <warpPolynomialOrder>1</warpPolynomialOrder>
      <interpolationMethod>Bilinear interpolation</interpolationMethod>
      <excludeMaster>false</excludeMaster>
      <openResidualsFile>false</openResidualsFile>
    </parameters>
  </node>
  <node id="Write">
    <operator>Write</operator>
    <sources>
      <sourceProduct refid="Warp"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>C:\Program Files\snap\coregistered_stack.tif</file>
      <formatName>GeoTIFF-BigTIFF</formatName>
    </parameters>
  </node>
  <node id="ProductSet-Reader">
    <operator>ProductSet-Reader</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <fileList>C:\Program Files\snap\S1A_input1.tif,C:\Program Files\snap\S1A_input2.tif</fileList>
    </parameters>
  </node>
</graph>

If you put those operators in a graph and run it in the GUI, does it work? If you run all the steps sequentially you will suffer a large performance decrease due to the extra reading and writing of intermediate products.

It works in the GUI and I also created the XML with the Graph-Builder, but in the command-line the same XML gives the error: “Operator ‘WriteOp’: Mandatory source product not set”.
However it would be best just to use the gpt operations without an XML, if it is possible.

The Graphs are in XML - why do you want to avoid XML?

I know but you can also use the direct commands like

gpt ProductSet-Reader -PfileList=…
gpt CreateStack [options] …
etc.

I’d prefer that but XML also works.

Anyway I would like to know how to make the automatic coregistration work in the command-line,
with or without XML.

maybe this post helps: Absolute beginner's guide to GPT

If you use the graph xml the processing will be faster because the intermediate results do not need to be written to the disk and read in again. Also some operators need to be called via a graph because the parametrisation is to complex for the command line.

I’d like to add that the performance benefit is generally large, even with SSD disks (highly recommended) many operations spend 90% of their time doing I/O.

Thank you for your help and your replies, but my question was related to the automatic coregistration. Anyway I think I figured it out now. Thanks again.

Hi, I have run into the same problem. Can you please tell me how you solved this problem?

I have solved it be re-arranging the operators in the XML file. Thanks.

I had the same issue, and moving up the “ProductSet-Reader” node as upper node of the .XML file solved it.

Hey marpet,
This thread is old, but I am interested in which processes need to be called in a graph? Since I am trying to automate stuff for work I am wondering if it even makes sense.

Please take a look at Bulk processing with gpt

Source : https://senbox.atlassian.net/wiki/spaces/SNAP/pages/70503475/Bulk+Processing+with+GPT

Thank you I will have a look!