GeoJSON Feature¶
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 GeoJSON Feature"
baseCommand: echo
requirements:
- class: InlineJavascriptRequirement
- class: SchemaDefRequirement
types:
- $import: https://raw.githubusercontent.com/eoap/schemas/main/geojson.yaml
inputs:
aoi:
type: https://raw.githubusercontent.com/eoap/schemas/main/geojson.yaml#Feature
label: "Area of interest"
doc: "Area of interest defined in GeoJSON format"
inputBinding:
valueFrom: |
${
// Validate if type is 'Feature'
if (inputs.aoi.type !== 'Feature') {
throw "Invalid GeoJSON type: expected 'Feature', got '" + inputs.aoi.type + "'";
}
// get the Feature geometry type
return "Feature with id '" + inputs.aoi.id + "' is of type: " + inputs.aoi.geometry.type;
}
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.
aoi:
class: https://raw.githubusercontent.com/eoap/schemas/main/geojson.yaml#Feature
id: "aoi-1"
type: "Feature"
bbox:
- 73.958
- -40.8003
- 73.9737
- 40.7648
geometry:
type: MultiPolygon
coordinates:
- - - - -73.958
- 40.8003
- - -73.9498
- 40.7968
- - -73.9737
- 40.7648
- - -73.9814
- 40.7681
- - -73.958
- 40.8003
- - - - -73.958
- 40.8003
- - -73.9498
- 40.7968
- - -73.9737
- 40.7648
- - -73.958
- 40.8003
bbox:
- 73.958
- -40.8003
- 73.9737
- 40.7648
Execute the example¶
Run the example with:
cwltool examples/geojson/feature.cwl examples/geojson/feature.yaml
This produces the output:
INFO /opt/hostedtoolcache/Python/3.12.12/x64/bin/cwltool 3.1.20251031082601
INFO Resolved '../../examples/geojson/feature.cwl' to 'file:///home/runner/work/schemas/schemas/examples/geojson/feature.cwl'
INFO [job feature.cwl] /tmp/owbtal8y$ echo \
'Feature with id '"'"'aoi-1'"'"' is of type: MultiPolygon' > /tmp/owbtal8y/echo_output.txt
INFO [job feature.cwl] completed success
INFO Final process status is success
The content of the echo_output.txt file is:
Feature with id 'aoi-1' is of type: MultiPolygon