Naming output files in GPT similarly to SNAP Desktop

I am writing a Python script to call GPT for batch processing of Sentinel data.

Is there any easy way to name files in the same manner using GPT as would happen if I ran the same graph in SNAP Desktop?

For example, I would read in a file C:\Imagery\S2\Ingest\S2A_MSIL2A_20200522T113331_N0214_R080_T29UPV_20200522T141706 and resample using the S2 Resampler to 20m to create: C:\Imagery\S2\20m\S2A_MSIL2A_20200522T113331_N0214_R080_T29UPV_20200522T141706_s2resampled.dim

Is there a specific function of dictionary/ hash that is called/referenced in order to add “_s2resampled” or whatever function was called to the name?

No, there is no such dictionary. You need to append this your self to the target file name.
You could also add a write operator to your graph. Then you can do the following:

  <node id="Write">
    <operator>Write</operator>
    <sources>
      <sourceProduct refid="S2Resample"/>
    </sources>
    <parameters>          
      <file>${outPath}_s2resampled.dim</file>
      <formatName>BEAM-DIMAP</formatName>
    </parameters>
  </node>

As additional parameter you would add

-PoutPath=targetPath_without_extension
1 Like

Thanks, I’ll create those then for my own applications.

I decided to create the dictionary, and will be collating my Python code online. I’d appreciate some help with developing the Python library, which I have named “OpenSNAPtools”. So far it only contains a JSON file with the SNAP GPT operators, their assumed abbreviations, sensor information if sensor specific, whether to ignore them in base filename concatenations, and descriptions from the help files. And yes, the operators and their descriptions were indeed taken from “gpt -h”.

1 Like