GPT graph not processing properly the graph.xml file

I am trying to automate the process of object detection using S-1 SAR data. I have created a graph in which I am importing vector dataset (shapefile) and using it for Land sea masking. The graph workflow works well when the vector data is located within the boundaries of the scene (SAR dataset i.e. S-1 GRD).But when the vector data is not overlapping with the scene boundaries(in this case I get the shape file as invalid and process stops). I have to run it over multiple SAR datasets so if any dataset is such that does not overlap with the vector boundaries it gives errros and stops.Can anyone please advise how to deal with such a case and in this case what changes I require to change in my graph ? (The shapefile name is shapefile.shp)

I am using command as :
gpt -Ps1_input=“Input” -Pport_shapefile=“shapefile.shp” -Poutput=“output”

I know I can change the landmask and useSRTM flags but I want to make it conditional i.e. only when there is no overlap…then I have to change the flags. Kindly advise.I am attaching the GPT graph.

<graph id="Graph">
  <version>1.0</version>
  <node id="Land-Sea-Mask">
    <operator>Land-Sea-Mask</operator>
    <sources>
      <sourceProduct refid="Import-Vector" />
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <sourceBands />
      <landMask>false</landMask>
      <useSRTM>false</useSRTM>
      <geometry>shape</geometry>
      <invertGeometry>false</invertGeometry>
      <shorelineExtension>0</shorelineExtension>
    </parameters>
  </node>
  <node id="Calibration">
    <operator>Calibration</operator>
    <sources>
      <sourceProduct refid="Land-Sea-Mask" />
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <sourceBands />
      <auxFile>Product Auxiliary File</auxFile>
      <externalAuxFile />
      <outputImageInComplex>false</outputImageInComplex>
      <outputImageScaleInDb>false</outputImageScaleInDb>
      <createGammaBand>false</createGammaBand>
      <createBetaBand>false</createBetaBand>
      <selectedPolarisations>VH,VV</selectedPolarisations>
      <outputSigmaBand>true</outputSigmaBand>
      <outputGammaBand>false</outputGammaBand>
      <outputBetaBand>false</outputBetaBand>
    </parameters>
  </node>
  <node id="AdaptiveThresholding">
    <operator>AdaptiveThresholding</operator>
    <sources>
      <sourceProduct refid="Calibration" />
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <targetWindowSizeInMeter>50</targetWindowSizeInMeter>
      <guardWindowSizeInMeter>500.0</guardWindowSizeInMeter>
      <backgroundWindowSizeInMeter>800.0</backgroundWindowSizeInMeter>
      <pfa>12.5</pfa>
      <estimateBackground>false</estimateBackground>
    </parameters>
  </node>
  <node id="Object-Discrimination">
    <operator>Object-Discrimination</operator>
    <sources>
      <sourceProduct refid="AdaptiveThresholding" />
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <minTargetSizeInMeter>30.0</minTargetSizeInMeter>
      <maxTargetSizeInMeter>600.0</maxTargetSizeInMeter>
    </parameters>
  </node>
  <node id="Read">
    <operator>Read</operator>
    <sources />
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>$s1_input</file>
    </parameters>
  </node>
  <node id="Import-Vector">
    <operator>Import-Vector</operator>
    <sources>
      <sourceProduct refid="Apply-Orbit-File" />
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <vectorFile>$port_shapefile</vectorFile>
      <separateShapes>false</separateShapes>
    </parameters>
  </node>
  <node id="Apply-Orbit-File">
    <operator>Apply-Orbit-File</operator>
    <sources>
      <sourceProduct refid="Read" />
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <orbitType>Sentinel Precise (Auto Download)</orbitType>
      <polyDegree>3</polyDegree>
      <continueOnFail>true</continueOnFail>
    </parameters>
  </node>
  <node id="Write">
    <operator>Write</operator>
    <sources>
      <sourceProduct refid="Object-Discrimination" />
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>$output</file>
      <formatName>BEAM-DIMAP</formatName>
    </parameters>
  </node>
  <applicationData id="Presentation">
    <Description />
    <node id="Land-Sea-Mask">
      <displayPosition x="102.0" y="182.0" />
    </node>
    <node id="Calibration">
      <displayPosition x="183.0" y="240.0" />
    </node>
    <node id="AdaptiveThresholding">
      <displayPosition x="281.0" y="241.0" />
    </node>
    <node id="Object-Discrimination">
      <displayPosition x="434.0" y="176.0" />
    </node>
    <node id="Read">
      <displayPosition x="31.0" y="44.0" />
    </node>
    <node id="Import-Vector">
      <displayPosition x="22.0" y="137.0" />
    </node>
    <node id="Apply-Orbit-File">
      <displayPosition x="19.0" y="88.0" />
    </node>
    <node id="Write">
      <displayPosition x="525.0" y="106.0" />
    </node>
  </applicationData>
</graph>

Do you want to do any processing on datasets that don’t overlap the shapefile boundaries? If not, you might look for ways to exclude those datasets so you never run gpt on them. Do two polygons intersect? has python examples. GIS packages (QGIS, ArcGIS) have tools to generate a shapefile for the footprint of a georeferenced image.

But how can I know the boundaries of a particular scene when I am directly processing a zip file of S-1 SAR ? I know when I have a tiff file I can do that but with a zip file ,it is not possible .

I have figured out the solution. In this special case, we can empty the geometry tag and make the landMask tag as true. So, the tags will be like this under Land-Sea Mask :

<landMask>true</landMask>

<useSRTM>false</useSRTM>

<geometry/>

This setup already ignores the vector shapefile. The work of the script increased a little bit in which I had to run the command of gpt two times :

  1. To check if there is no error,the script will clip the scene for a given shapefile.
  2. In case the shapefile and scene don’t overlap, an error can be catched displaying “Undefined shapefile”. Then change the tags as per above setup and run the above gpt command to get the desired result.
2 Likes