Skip to content

STAC Catalog

Goal

Wrap the stac step as a Common Workflow Language CommandLineTool and execute it with a CWL runner.

CWL CommandLineTool wrapping the step

The CWL document below shows the stac step wrapped as a CWL CommandLineTool:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
cwlVersion: v1.0

class: CommandLineTool
id: stac
requirements:
  InlineJavascriptRequirement: {}
  EnvVarRequirement:
    envDef:
      PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
      PYTHONPATH: /app
  ResourceRequirement:
    coresMax: 1
    ramMax: 512
hints:
  DockerRequirement:
    dockerPull: localhost/stac:latest 
baseCommand: ["python", "-m", "app"]
arguments: []
inputs:
  item:
    type: string
    inputBinding:
      prefix: --input-item
  raster:
    type: File
    inputBinding:
      prefix: --water-body
outputs:
  stac_catalog:
    outputBinding:
      glob: .
    type: Directory

Steps

Run the CWL document using the cwltool CWL runner to execute the stac step with:

1
2
3
4
5
6
7
8
cwltool \
    --podman \
    --outdir /workspace/runs \
    ${WORKSPACE}/cwl-cli/stac.cwl \
    --item \
    "https://earth-search.aws.element84.com/v0/collections/sentinel-s2-l2a-cogs/items/S2B_10TFK_20210713_0_L2A" \
    --raster \
    /workspace/runs/otsu.tif
sh -x ${WORKSPACE}/scripts/cwl-cli-stac.sh

Expected outcome

The folder /workspace/runs contains:

(base) jovyan@coder-fbrito:~/runs$ tree .
.
├── crop_green.tif
├── crop_nir.tif
├── norm_diff.tif
├── otsu.tif
└── p371fwrs
    ├── S2B_10TFK_20210713_0_L2A
    │   ├── S2B_10TFK_20210713_0_L2A.json
    │   └── otsu.tif
    └── catalog.json

2 directories, 7 files

Line #6 shows the folder created by the execution.