STAC catalog
Goal
Wrap the stac step as a Common Workflow Language CommandLineTool and execute it with a CWL runner.
Lab
This step has a dedicated lab at practice-labs/3-CWL-CommandLineTools/stac.ipynb.
The CWL document below shows the stac step wrapped as a CWL CommandLineTool:
| cwlVersion: v1.2
$namespaces:
s: https://schema.org/
# Training-example authors and creation date mirror codemeta.json.
s:name: STAC catalog
s:description: Create a STAC catalog for the water body detection results.
s:dateCreated: '2022-09-01'
s:license:
s:name: Creative Commons Attribution-ShareAlike 4.0 International
s:url: https://creativecommons.org/licenses/by-sa/4.0/
s:identifier: CC-BY-SA-4.0
s:softwareHelp:
s:name: Mastering Earth Observation Application Packaging with CWL
s:url: https://eoap.github.io/mastering-app-package
s:publisher:
s:name: EO Application Packaging
s:identifier: https://github.com/eoap
s:author:
- s:givenName: Jane
s:familyName: Doe
s:email: jane.doe@acme.earth
s:affiliation:
s:name: ACME
- s:givenName: John
s:familyName: Doe
s:email: john.doe@acme.earth
s:affiliation:
s:name: ACME
s:softwareRequirements:
- container runtime
- cwl runner
s:softwareVersion: 2.0.2
class: CommandLineTool
id: stac
requirements:
InlineJavascriptRequirement: {}
EnvVarRequirement:
envDef:
PATH: /app/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ResourceRequirement:
coresMax: 1
ramMax: 512
NetworkAccess:
networkAccess: true
DockerRequirement:
dockerPull: localhost/stac:latest
baseCommand: stac
arguments: []
inputs:
item:
type: string
inputBinding:
prefix: --item
label: STAC item
doc: STAC item reference identifying the source acquisition.
raster:
type: File
inputBinding:
prefix: --rasters
label: Water index raster
doc: Normalized difference water index raster to threshold.
outputs:
stac_catalog:
outputBinding:
glob: .
type: Directory
label: Results STAC catalog
doc: Directory containing the results STAC catalog and its referenced raster assets.
|
Steps
Run the CWL document using the cwltool CWL runner to execute the stac step with:
| export WORKSPACE=/workspace/mastering-app-package
export RUNTIME=${WORKSPACE}/runs
mkdir -p ${RUNTIME}
cd ${RUNTIME}
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/mastering-app-package/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 #7 shows the folder created by the execution.