STAC Catalog¶
CWL example¶
# Copyright 2025 Terradue
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cwlVersion: v1.2
class: CommandLineTool
label: "Echo STAC Catalog"
baseCommand: echo
requirements:
- class: InlineJavascriptRequirement
- class: SchemaDefRequirement
types:
- $import: https://raw.githubusercontent.com/eoap/schemas/main/stac.yaml
inputs:
stac_catalog:
type: https://raw.githubusercontent.com/eoap/schemas/main/stac.yaml#Catalog
label: "STAC Catalog"
doc: "STAC Catalog defined in STAC format"
inputBinding:
valueFrom: |
${
// Validate if type is 'Feature'
if ('Catalog' !== inputs.stac_catalog.type) {
throw "Invalid STAC type: expected 'Catalog', got '" + inputs.stac_catalog.type + "'";
}
// get the STAC Catalog description
return "STAC Catalog description: " + inputs.stac_catalog.description;
}
outputs:
echo_output:
type: stdout
stdout: echo_output.txt
Input example¶
# Copyright 2025 Terradue
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
stac_catalog:
class: "https://raw.githubusercontent.com/eoap/schemas/main/stac.yaml#Catalog"
id: "stac-catalog"
type: "Catalog"
title: "STAC Catalog Example"
description: "An example STAC catalog"
stac_version: "1.0.0"
stac_extensions:
- "https://raw.githubusercontent.com/radiantearth/stac-api-spec/refs/tags/v1.0.0/extensions/eo/v1.0.0/schema.json"
links:
- rel: "self"
href: "http://example.com/catalog.json"
type: "application/json"
title: "This catalog"
- rel: item
href: "https://earth-search.aws.element84.com/v0/collections/sentinel-s2-l2a-cogs/items/S2A_10TFK_20220524_0_L2A"
type: "application/json"
title: "This is the input item"
Execute the example¶
Run the example with:
cwltool examples/stac/catalog.cwl examples/stac/catalog.yaml
This produces the output:
INFO /opt/hostedtoolcache/Python/3.12.12/x64/bin/cwltool 3.1.20251031082601
INFO Resolved '../../examples/stac/catalog.cwl' to 'file:///home/runner/work/schemas/schemas/examples/stac/catalog.cwl'
INFO [job catalog.cwl] /tmp/keni2xop$ echo \
'STAC Catalog description: An example STAC catalog' > /tmp/keni2xop/echo_output.txt
INFO [job catalog.cwl] completed success
INFO Final process status is success
The content of the echo_output.txt file is:
STAC Catalog description: An example STAC catalog