9  LCZ Preprocessing

9.1 Introduction

The following sections demonstrate that the HEATWISE Local Climate Zones pre-processing software follows the OGC Best Practice for Earth Observation Application Package.

The order of demonstration is deliberately different from that given in the best practice document. This is done to make the demonstration easy to follow and group requirements that can be shown together. An effort is made to keep the requirements in order as much as possible to make it easy to find a specific requirement.

The demonstration proceeds in the following steps:

  • Execute the software as docker container and as CWL document (the EOAP)
  • Show that STAC inputs and outputs are handled by the application as required
  • Show that the CWL document is structured as required
  • Show that STAC inputs and outputs are declared in the CWL as required

After each step, the requirements shown are listed.

Chapter 2 contains an overview of all requirements in order and how they are demonstrated in this document. It furthermore shows all utility scripts used in this demonstration. For brevity, the content of utility scripts is only shown in the requirements overview and not in each demonstration.

9.2 Preparation

Activate the pixi environment to make validation tools and scripts available.

eval "$(pixi shell-hook --change-ps1 false)"

Set environment variables to software, cwl documents, inputs and outputs.

set -o pipefail
set -x
SOFTWARE_ROOT="$PIXI_PROJECT_ROOT"/software/heatwise-hsi-lst-prep
CWL_PATH="$PIXI_PROJECT_ROOT"/application-packages/heatwise_hsi_lst_prep.cwl
INPUT_PATH="$PIXI_PROJECT_ROOT"/inputs/hsi-lst-prep

DOCKER_IMAGE_ID=ghcr.io/esa-heatwise/heatwise-hsi-lst-prep:1.0.0
OUTPUT_PATH="$PIXI_PROJECT_ROOT"/outputs/hsi-lst-prep

ls -ltrAh --color=never "$SOFTWARE_ROOT"
set +x
+ SOFTWARE_ROOT=/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/software/heatwise-hsi-lst-prep
+ CWL_PATH=/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/application-packages/heatwise_hsi_lst_prep.cwl
+ INPUT_PATH=/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/inputs/hsi-lst-prep
+ DOCKER_IMAGE_ID=ghcr.io/esa-heatwise/heatwise-hsi-lst-prep:1.0.0
+ OUTPUT_PATH=/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep
+ ls --color=auto -ltrAh --color=never /home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/software/heatwise-hsi-lst-prep
total 76K
-rw-r--r-- 1 runner runner  159 Nov 27 10:37 .gitignore
-rw-r--r-- 1 runner runner 1.3K Nov 27 10:37 Dockerfile
-rw-r--r-- 1 runner runner  13K Nov 27 10:37 README.md
-rw-r--r-- 1 runner runner 1.1K Nov 27 10:37 LICENSE
-rw-r--r-- 1 runner runner  261 Nov 27 10:37 .dockerignore
drwxr-xr-x 2 runner runner 4.0K Nov 27 10:37 data
drwxr-xr-x 3 runner runner 4.0K Nov 27 10:37 examples
-rw-r--r-- 1 runner runner  18K Nov 27 10:37 processor.py
-rw-r--r-- 1 runner runner 4.3K Nov 27 10:37 heatwise_hsi_lst_prep.cwl
-rw-r--r-- 1 runner runner   48 Nov 27 10:37 requirements.txt
drwxr-xr-x 7 runner runner 4.0K Nov 27 10:37 .git
+ set +x

9.3 Running the software

The first set of requirements is concerned with how the software is executed. It shall be

  • Runnable as a non-interactive script
  • Bundled in (Docker) container
  • Executable as a CWL Workflow containing at least one CWL CommandLineTool

9.3.1 Running as a docker container

We can run the (dockerized) software directly, without using the CWL machinery with docker run:

mkdir -p "$OUTPUT_PATH"

docker run --rm \
  -v "$SOFTWARE_ROOT/examples:/app/examples" \
  -v "$INPUT_PATH/data:/app/data" \
  -v "$INPUT_PATH:/inputs" \
  -v "$OUTPUT_PATH:/app/output" \
  --user "$(id -u):$(id -g)" \
  $DOCKER_IMAGE_ID \
  python /app/processor.py run-all \
    --config /app/examples/run_all_config_docker.yaml \
    --input-catalog /inputs/catalog.json \
    --output-dir /app/output \
    || { FAIL_REQ_1=1; FAIL_REQ_2=1; }
[run-all] Loaded 1 city/cities from STAC catalog: /inputs/catalog.json
[band_trim] Saved /app/output/01_trimmed/Berlin_trimmed.tif (124 bands kept)
Target resolution: 10 m | Regression method: linear

=== Berlin_trimmed.tif  <-  Berlin_S2.tif ===
  Resampling Sentinel-2 -> 10m nested grid (810x537) ...
  S2 gap pixels inside footprint: 545 -> nearest-neighbor fill
  Training pixels: 48311 / 48330
  Fitting and predicting (method=linear) ...
  Saved: /app/output/02_sharpened_10m/Berlin_trimmed_sharp10m.tif  (124 bands, 810x537, 10m)

All done. Results in: /app/output/02_sharpened_10m

Processing Berlin
  Bands: 124, valid pixels: 48311
  Selected bands (0-based, 55): [2, 7, 9, 10, 13, 15, 17, 20, 24, 28, 29, 30, 31, 32, 33, 34, 35, 37, 41, 52, 63, 67, 69, 70, 71, 72, 74, 80, 85, 89, 91, 94, 96, 98, 99, 100, 101, 102, 104, 105, 107, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122]

Voting result (0-based): [2, 7, 9, 10, 13, 15, 17, 20, 24, 28, 29, 30, 31, 32, 33, 34, 35, 37, 41, 52, 63, 67, 69, 70, 71, 72, 74, 80, 85, 89, 91, 94, 96, 98, 99, 100, 101, 102, 104, 105, 107, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122]

Final 30 bands (0-based): [2, 7, 13, 17, 20, 24, 28, 32, 37, 41, 52, 63, 67, 71, 74, 80, 85, 89, 94, 98, 102, 104, 107, 109, 111, 113, 115, 117, 119, 121]

Saved selection to /app/output/band_selection.json
Loaded 30 selected bands from json: [3, 8, 14, 18, 21, 25, 29, 33, 38, 42, 53, 64, 68, 72, 75, 81, 86, 90, 95, 99, 103, 105, 108, 110, 112, 114, 116, 118, 120, 122]
[apply_band_selection] Saved /app/output/03_hsi_final/hsi_bs/Berlin_hsi_bs.tif (30 bands)
[lst] Source: 7 bands, (50.0, 50.0), EPSG:32633, nodata=nan
[lst] Resampled onto reference grid 810x537; valid fraction 98.6%
[lst] Normalized (zscore): min/med/max = -4.463/0.019/3.318
[lst] Saved: /app/output/04_lst_final/Berlin_lst_final.tif  (+ /app/output/04_lst_final/Berlin_lst_final.json)
[stac_io] Wrote output catalogue: /app/output/catalog.json (1 item(s))

[run-all] All done. Output directory: /app/output

The image should not only be available locally, but also in a container registry.

check-container-registry.sh $DOCKER_IMAGE_ID || FAIL_REQ_3=1
SUCCESS: Image ghcr.io/esa-heatwise/heatwise-hsi-lst-prep:1.0.0 found on registry

9.3.1.1 Requirements Validated

req/app/cmd-line (Requirement 1)

The Application SHALL be a non-interactive executable as a command-line application.

req/app/container (Requirement 2)

The environment, libraries, binaries, executable and configuration files necessary to execute the Application SHALL be bundled in a container image.

req/app/registry (Requirement 3)

The Application container image SHALL be accessible in a container registry.

9.3.2 Running as an EOAP

First, we validate that the CWL document is valid.

cwltool --disable-color --validate "$CWL_PATH" | cat
INFO /home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/.pixi/envs/dev/bin/cwltool 3.2.20260413085819
INFO Resolved '/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/application-packages/heatwise_hsi_lst_prep.cwl' to 'file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/application-packages/heatwise_hsi_lst_prep.cwl'
/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/application-packages/heatwise_hsi_lst_prep.cwl is valid CWL.

The CWL should contain a Workflow and at least one CommandLineTool object. We inspect the classes in the CWL graph to make sure.

show-cwl-graph-classes.sh "$CWL_PATH"
class: Workflow
id: main
---
class: CommandLineTool
id: hsi_lst_prep_processor

The EOAP can be executed from its CWL description with cwltool.

cwltool \
  --disable-color \
  --outdir "$OUTPUT_PATH/cwlruns" \
   $CWL_PATH \
  --input_catalog $INPUT_PATH \
  --config $SOFTWARE_ROOT/examples/run_all_config_docker.yaml \
  || FAIL_REQ_7=1
INFO /home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/.pixi/envs/dev/bin/cwltool 3.2.20260413085819
INFO Resolved '/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/application-packages/heatwise_hsi_lst_prep.cwl' to 'file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/application-packages/heatwise_hsi_lst_prep.cwl'
INFO [workflow ] start
INFO [workflow ] starting step processor
INFO [step processor] start
INFO [job processor] /tmp/6yedm01t$ docker \
    run \
    -i \
    --mount=type=bind,source=/tmp/6yedm01t,target=/XOUtvf \
    --mount=type=bind,source=/tmp/67b_8bok,target=/tmp \
    --mount=type=bind,source=/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/software/heatwise-hsi-lst-prep/examples/run_all_config_docker.yaml,target=/var/lib/cwl/stg02716ed5-f159-490e-9f19-c070d7175ff0/run_all_config_docker.yaml,readonly \
    --mount=type=bind,source=/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/inputs/hsi-lst-prep,target=/var/lib/cwl/stg2a09aab9-25e4-457d-ad1a-b52b80dc3fa6/hsi-lst-prep,readonly \
    --workdir=/XOUtvf \
    --read-only=true \
    --net=none \
    --user=1001:1001 \
    --rm \
    --cidfile=/tmp/lfqr8tpz/20261127104647-075934.cid \
    --env=TMPDIR=/tmp \
    --env=HOME=/XOUtvf \
    ghcr.io/esa-heatwise/heatwise-hsi-lst-prep:1.0.0 \
    python \
    /app/processor.py \
    run-all \
    --config \
    /var/lib/cwl/stg02716ed5-f159-490e-9f19-c070d7175ff0/run_all_config_docker.yaml \
    --input-catalog \
    /var/lib/cwl/stg2a09aab9-25e4-457d-ad1a-b52b80dc3fa6/hsi-lst-prep/catalog.json \
    --output-dir \
    .
[run-all] Loaded 1 city/cities from STAC catalog: /var/lib/cwl/stg2a09aab9-25e4-457d-ad1a-b52b80dc3fa6/hsi-lst-prep/catalog.json
[band_trim] Saved 01_trimmed/Berlin_trimmed.tif (124 bands kept)
Target resolution: 10 m | Regression method: linear

=== Berlin_trimmed.tif  <-  Berlin_S2.tif ===
  Resampling Sentinel-2 -> 10m nested grid (810x537) ...
  S2 gap pixels inside footprint: 545 -> nearest-neighbor fill
  Training pixels: 48311 / 48330
  Fitting and predicting (method=linear) ...
  Saved: 02_sharpened_10m/Berlin_trimmed_sharp10m.tif  (124 bands, 810x537, 10m)

All done. Results in: 02_sharpened_10m

Processing Berlin
  Bands: 124, valid pixels: 48311
  Selected bands (0-based, 55): [2, 7, 9, 10, 13, 15, 17, 20, 24, 28, 29, 30, 31, 32, 33, 34, 35, 37, 41, 52, 63, 67, 69, 70, 71, 72, 74, 80, 85, 89, 91, 94, 96, 98, 99, 100, 101, 102, 104, 105, 107, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122]

Voting result (0-based): [2, 7, 9, 10, 13, 15, 17, 20, 24, 28, 29, 30, 31, 32, 33, 34, 35, 37, 41, 52, 63, 67, 69, 70, 71, 72, 74, 80, 85, 89, 91, 94, 96, 98, 99, 100, 101, 102, 104, 105, 107, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122]

Final 30 bands (0-based): [2, 7, 13, 17, 20, 24, 28, 32, 37, 41, 52, 63, 67, 71, 74, 80, 85, 89, 94, 98, 102, 104, 107, 109, 111, 113, 115, 117, 119, 121]

Saved selection to band_selection.json
Loaded 30 selected bands from json: [3, 8, 14, 18, 21, 25, 29, 33, 38, 42, 53, 64, 68, 72, 75, 81, 86, 90, 95, 99, 103, 105, 108, 110, 112, 114, 116, 118, 120, 122]
[apply_band_selection] Saved 03_hsi_final/hsi_bs/Berlin_hsi_bs.tif (30 bands)
[lst] Source: 7 bands, (50.0, 50.0), EPSG:32633, nodata=nan
[lst] Resampled onto reference grid 810x537; valid fraction 98.6%
[lst] Normalized (zscore): min/med/max = -4.463/0.019/3.318
[lst] Saved: 04_lst_final/Berlin_lst_final.tif  (+ 04_lst_final/Berlin_lst_final.json)
[stac_io] Wrote output catalogue: catalog.json (1 item(s))

[run-all] All done. Output directory: .
INFO [job processor] Max memory used: 1278MiB
INFO [job processor] completed success
INFO [step processor] completed success
INFO [workflow ] completed success
{
    "output": {
        "location": "file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t",
        "basename": "6yedm01t",
        "class": "Directory",
        "listing": [
            {
                "class": "Directory",
                "location": "file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/01_trimmed",
                "basename": "01_trimmed",
                "listing": [
                    {
                        "class": "File",
                        "location": "file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/01_trimmed/Berlin_trimmed.tif",
                        "basename": "Berlin_trimmed.tif",
                        "size": 26786504,
                        "checksum": "sha1$2e6fd2fffee196fd159536d8214fe7573fd9dc83",
                        "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/01_trimmed/Berlin_trimmed.tif"
                    }
                ],
                "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/01_trimmed"
            },
            {
                "class": "Directory",
                "location": "file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/03_hsi_final",
                "basename": "03_hsi_final",
                "listing": [
                    {
                        "class": "Directory",
                        "location": "file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/03_hsi_final/hsi_bs",
                        "basename": "hsi_bs",
                        "listing": [
                            {
                                "class": "File",
                                "location": "file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/03_hsi_final/hsi_bs/Berlin_hsi_bs.tif",
                                "basename": "Berlin_hsi_bs.tif",
                                "size": 46153035,
                                "checksum": "sha1$5155ac43041e82013559c0eb340e536ec32a1e8b",
                                "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/03_hsi_final/hsi_bs/Berlin_hsi_bs.tif"
                            }
                        ],
                        "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/03_hsi_final/hsi_bs"
                    }
                ],
                "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/03_hsi_final"
            },
            {
                "class": "File",
                "location": "file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/catalog.json",
                "basename": "catalog.json",
                "size": 271,
                "checksum": "sha1$75230bdbf7fa5903db2b3539ecbc5c1af368f044",
                "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/catalog.json"
            },
            {
                "class": "Directory",
                "location": "file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/04_lst_final",
                "basename": "04_lst_final",
                "listing": [
                    {
                        "class": "File",
                        "location": "file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/04_lst_final/Berlin_lst_final.tif",
                        "basename": "Berlin_lst_final.tif",
                        "size": 1433802,
                        "checksum": "sha1$144ebb58ee953d37e53c29fd2364ab2c725ed76b",
                        "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/04_lst_final/Berlin_lst_final.tif"
                    },
                    {
                        "class": "File",
                        "location": "file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/04_lst_final/Berlin_lst_final.json",
                        "basename": "Berlin_lst_final.json",
                        "size": 285,
                        "checksum": "sha1$beccf96813ac65f485440eed7ef31b4908cb4ec6",
                        "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/04_lst_final/Berlin_lst_final.json"
                    }
                ],
                "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/04_lst_final"
            },
            {
                "class": "Directory",
                "location": "file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/02_sharpened_10m",
                "basename": "02_sharpened_10m",
                "listing": [
                    {
                        "class": "File",
                        "location": "file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/02_sharpened_10m/Berlin_trimmed_sharp10m.tif",
                        "basename": "Berlin_trimmed_sharp10m.tif",
                        "size": 188281066,
                        "checksum": "sha1$f82ae4b6507bff32015997b3d359c49e68b3b4d7",
                        "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/02_sharpened_10m/Berlin_trimmed_sharp10m.tif"
                    }
                ],
                "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/02_sharpened_10m"
            },
            {
                "class": "File",
                "location": "file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/Berlin_item.json",
                "basename": "Berlin_item.json",
                "size": 1629,
                "checksum": "sha1$a0ef925849cd9dbb7552b9bc6555b605ec9d0ac1",
                "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/Berlin_item.json"
            },
            {
                "class": "File",
                "location": "file:///home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/band_selection.json",
                "basename": "band_selection.json",
                "size": 2344,
                "checksum": "sha1$db237edbfa2a67b0b28810bb23218c4bfd07d9eb",
                "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/band_selection.json"
            }
        ],
        "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t"
    }
}INFO Final process status is success

Cwltool creates a new output directory with a random name when it is run. We save the last run in a variable to access it later.

CWLRUN_PATH=$(find-newest-directory-entry.sh "$OUTPUT_PATH/cwlruns")
echo "Path to last cwl run: $CWLRUN_PATH"
Path to last cwl run: /home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t

9.3.2.1 Requirements Validated

req/app-pck/cwl (Requirement 7)

The Application Package SHALL be a valid CWL document with a “Workflow” class and one or more “CommandLineTool” classes.

9.3.2.2 EOAP Output

tree -n $CWLRUN_PATH || :
/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t
├── 01_trimmed
│   └── Berlin_trimmed.tif
├── 02_sharpened_10m
│   └── Berlin_trimmed_sharp10m.tif
├── 03_hsi_final
│   └── hsi_bs
│       └── Berlin_hsi_bs.tif
├── 04_lst_final
│   ├── Berlin_lst_final.json
│   └── Berlin_lst_final.tif
├── Berlin_item.json
├── band_selection.json
└── catalog.json

6 directories, 8 files
python -c "import numpy as np; \
    import matplotlib.pyplot as plt; \
    import xarray as xr; \
    import rioxarray as rio; \
    ds_hsi=rio.open_rasterio(\"$CWLRUN_PATH/03_hsi_final/hsi_bs/Berlin_hsi_bs.tif\"); \
    fig, ax = plt.subplots(); \
    ds_hsi_subset = ds_hsi.sel(band=[7, 3, 2]); \
    xr.where(ds_hsi_subset < 0, np.nan, ds_hsi_subset ** 0.5).plot.imshow(ax=ax); \
    fig.savefig('hsi_preprocessed.png'); \
    ds_hsi.close()" || :

Preprocessed HSI data

9.4 STAC input / output

9.4.1 Inputs

The EO Products of the input are provided as directories with a catalog.json describing the products each:

ls -lAhX --color=never $INPUT_PATH/*
-rw-r--r-- 1 runner runner 1.1K Nov 27 10:37 /home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/inputs/hsi-lst-prep/Berlin_item.json
-rw-r--r-- 1 runner runner 1.2K Nov 27 10:37 /home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/inputs/hsi-lst-prep/Berlin_item_docker.json
-rw-r--r-- 1 runner runner  284 Nov 27 10:37 /home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/inputs/hsi-lst-prep/catalog.json
-rw-r--r-- 1 runner runner  493 Nov 27 10:37 /home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/inputs/hsi-lst-prep/catalog_docker.json
-rw-r--r-- 1 runner runner  44M Nov 27 10:37 /home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/inputs/hsi-lst-prep/Berlin_CHIME.tif
-rw-r--r-- 1 runner runner 503K Nov 27 10:37 /home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/inputs/hsi-lst-prep/Berlin_LSTM.tif
-rw-r--r-- 1 runner runner 9.9M Nov 27 10:37 /home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/inputs/hsi-lst-prep/Berlin_S2.tif

/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/inputs/hsi-lst-prep/data:
total 4.0K
-rw-r--r-- 1 runner runner 3.2K Nov 27 10:37 CHIME_v2_wavelengths_um.txt

These same inputs are classed as Directory in the workflow:

extract-directory-inputs-from.sh Workflow "$CWL_PATH" || FAIL_REQ_4=1
Running
inputs_with_directory_type:
  - id: input_catalog
    type: Directory
    label: input STAC catalog
    doc: 'Directory containing a STAC catalog named catalog.json referencing

      the staged EO input products required by the preprocessing workflow,

      such as hyperspectral imagery, Sentinel-2 imagery, and LST products.

      '

9.4.2 Outputs

The output contains a single catalog.json and item, describing the output. Using the recursive validation, both the catalog and item are confirmed to be valid STAC.

(stac-validator validate --recursive $CWLRUN_PATH/catalog.json | cat) || FAIL_REQ_5=1

Thanks for using STAC version 1.1.0!

[
    {
        "version": "1.1.0",
        "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/catalog.json",
        "schema": [
            "https://schemas.stacspec.org/v1.1.0/catalog-spec/json-schema/catalog.json"
        ],
        "valid_stac": true,
        "asset_type": "CATALOG",
        "validation_method": "recursive",
        "validator_engine": "jsonschema"
    },
    {
        "version": "1.1.0",
        "path": "/home/runner/work/heatwise-interoperability-demonstration/heatwise-interoperability-demonstration/outputs/hsi-lst-prep/cwlruns/6yedm01t/Berlin_item.json",
        "schema": [
            "https://stac-extensions.github.io/processing/v1.2.0/schema.json",
            "https://schemas.stacspec.org/v1.1.0/item-spec/json-schema/item.json"
        ],
        "valid_stac": true,
        "asset_type": "ITEM",
        "validation_method": "recursive",
        "validator_engine": "jsonschema"
    }
]

-- Recursive Validation Summary:
  Stac objects passed: 2/2 (100.0%)

  Breakdown by type:
    Catalog: 1/1 (100.0%)
    Item: 1/1 (100.0%)

Validation completed in 204.27ms

The EOAP best practice mandates that the item contains at least geometry, bbox and datetime keys.

extract-output-keys-from-stac-item.sh $CWLRUN_PATH/Berlin_item.json || FAIL_REQ_6=1
geometry:
  type: Polygon
  coordinates: '[...truncated...]'
bbox:
  - 13.255963533307378
  - 52.448078953513594
  - 13.33782034204588
  - 52.5220055613443
properties:
  datetime: null
  start_datetime: '2009-08-20T00:00:00Z'
  end_datetime: '2023-07-09T23:59:59Z'

Required keys present: true

9.4.3 Requirements Validated

req/app/stac-input (Requirement 4)

An Application input argument that requires staged EO product files SHALL be defined as an argument that points to a folder where a STAC Catalog, named catalog.json, contains a list of one or more STAC Items and associated STAC Assets referencing the files.

req/app/stac-out (Requirement 5)

An Application that creates EO product files to be stage-out SHALL generate a valid STAC Catalog, named catalog.json, and include the STAC Item(s) and corresponding STAC Assets pointing to the results of the processing.

rec/app/stac-out-metadata (Requirement 6)

The STAC Catalog created by the Application SHALL include metadata elements for each STAC Item with at least their spatial (geometry, box) and temporal (datetime) properties.

9.5 CWL

The fields id, baseCommand, inputs, requirements should be present in the CommandLineTool. One of the requirements should be DockerRequirement.

check-commandlinetool-fields.sh "$CWL_PATH" || FAIL_REQ_8=1
id: hsi_lst_prep_processor
baseCommand: python
requirements:
  DockerRequirement:
    dockerPull: ghcr.io/esa-heatwise/heatwise-hsi-lst-prep:1.0.0
  InlineJavascriptRequirement: {}
Required keys present: true

The fields id, label, and doc should be present in the Workflow.

check-workflow-fields.sh "$CWL_PATH" || FAIL_REQ_9=1
id: main
label: HEATWISE HSI/LST Preprocessing Workflow
doc: 'EOAP-compatible HEATWISE HSI/LST preprocessing workflow.


  The workflow runs the per-city preprocessing chain used by the

  HEATWISE LCZ mapping workflow, including hyperspectral band trimming,

  sharpening, cross-city band selection and application, optional

  cross-city PCA, and optional LST processing.


  EO input products are provided through a staged STAC catalog directory.

  The processor generates the corresponding preprocessing products and

  an output STAC catalog describing the EO products.

  '
Required keys present: true

Each input of the Workflow should have fields id, label, and doc

check-workflow-input-fields.sh $CWL_PATH || FAIL_REQ_10=1
inputs:
  - id: 0
    label: processing configuration
    doc: 'Run-level YAML configuration controlling the HSI/LST preprocessing

      workflow, including LST/PCA processing options, band-selection and

      PCA parameters, wavelength information, and city configuration.

      '
  - id: 1
    label: input STAC catalog
    doc: 'Directory containing a STAC catalog named catalog.json referencing

      the staged EO input products required by the preprocessing workflow,

      such as hyperspectral imagery, Sentinel-2 imagery, and LST products.

      '
  - id: 2
    label: output directory
    doc: 'Output directory path relative to the CWL working directory.

      By default, products are written directly to the working directory.

      '

The CWL document should contain a version:

check-version.sh $CWL_PATH || FAIL_REQ_11=1
s:version: 1.0.0
https://schema.org/version: null
Found version:  true

9.5.1 Requirements Validated

req/app-pck/clt (Requirement 8)

The Application Package CWL CommandLineTool classes SHALL contain the following elements:

  • Identifier (“id”)
  • Command line name (“baseCommand”)
  • Input parameters (“inputs”)
  • Environment requirements (“requirements”)
  • Docker information (“DockerRequirement”)

req/app-pck/wf (Requirement 9)

The Application Package CWL Workflow class SHALL contain the following elements:

  • Identifier (“id”)
  • Title (“label”)
  • Abstract (“doc”)

req/app-pck/wf-inputs (Requirement 10)

The Application Package CWL Workflow class “inputs” fields SHALL contain the following elements:

  • Identifier (“id”)
  • Title (“label”)
  • Abstract (“doc”)

req/app-pck/metadata (Requirement 11)

The Application Package CWL Workclass classes SHALL include additional metadata as defined in Table 1

Required in table 1: version

9.6 CWL STAC / IO

Inputs and outputs are staged in and out using STAC catalogs. Each input that is an “EO Product” like a vector or raster dataset is declared as type Directory and is described by a STAC catalog catalog.json and accompanying STAC item(s) placed in that directory.

Outputs are handled in much the same way, the application in the application package is responsible for generating a STAC catalog (also named catalog.json) and stage out all the contents of its working directory together with the STAC metadata describing the outputs.

9.6.1 Inputs

There are inputs of type directory in the CommandLineTool description.

extract-directory-inputs-from.sh CommandLineTool "$CWL_PATH" || FAIL_REQ_12=1
Running
inputs_with_directory_type:
  - type: Directory
    label: input STAC catalog
    doc: 'Directory containing catalog.json and the associated STAC Items and

      Assets for the staged EO input products.


      The path to catalog.json inside this directory is passed to the

      processor through the --input-catalog argument.

      '
    inputBinding:
      prefix: --input-catalog
      valueFrom: $(self.path + "/catalog.json")

There are inputs of type directory in the Workflow description.

extract-directory-inputs-from.sh Workflow "$CWL_PATH" || FAIL_REQ_13=1
Running
inputs_with_directory_type:
  - id: input_catalog
    type: Directory
    label: input STAC catalog
    doc: 'Directory containing a STAC catalog named catalog.json referencing

      the staged EO input products required by the preprocessing workflow,

      such as hyperspectral imagery, Sentinel-2 imagery, and LST products.

      '

9.6.2 Outputs

The CommandLineTool stages out all the contents of the working directory.

extract-commandlinetool-outputs.sh "$CWL_PATH" || FAIL_REQ_14=1
output:
  type: Directory
  doc: 'Complete CWL working directory containing all files produced by the

    processor, including the preprocessing products and the generated

    STAC catalog.

    '
  outputBinding:
    glob: .
Extracts all items from Working directory: true

9.6.3 Requirements validated

req/app-pck-stage-in/clt-stac (Requirement 12)

All input parameters of the CWL ComandLineTool that require the staging of EO products SHALL be of type Directory.

req/app-pck-stage-in/wf-stac (Requirement 13)

Input parameters of the CWL Workflow that require the staging of EO products SHALL be of type Directory.

req/app-pck-stage-out/output-stac (Requirement 14)

The outputs field of the CommandLineTool that requires the stage-out of EO products SHALL retrieve all the files produced in the working directory.

9.7 Summary

for i in {1..14}; do
    var="FAIL_REQ_$i"
    req=${var#FAIL_}
    if [[ "${!var:-}" == "1" ]]; then
        #echo "$req: FAILED"
        printf '%s\t\033[31mFAILED\033[0m\n' "$req"
    else
        printf '%s\t\033[32mPASSED\033[0m\n' "$req"
    fi
done
REQ_1  PASSED

REQ_2   PASSED

REQ_3   PASSED

REQ_4   PASSED

REQ_5   PASSED

REQ_6   PASSED

REQ_7   PASSED

REQ_8   PASSED

REQ_9   PASSED

REQ_10  PASSED

REQ_11  PASSED

REQ_12  PASSED

REQ_13  PASSED

REQ_14  PASSED

The pre-processing step of the Local Climate Zone classification software has been shown to be non-interactively executable from the command line and using a CWL runner (cwltool). Furthermore it follows the CWL structure and mandatory fields prescribed by the OGC Best Practice for Earth Observation Application Package (EOAP). Inputs and outputs are processed as CWL Directories and valid STAC metadata is generated for the output. It may therefore be concluded that the software behaves as expected by the EOAP best practice in the example scenario.

No conclusive judgment on the adherence to all requirements listed in Chapter 2 under all valid input conditions can be made without inspection of the source code. The demonstration evaluates the statically available information (the CWL document, and container image) as well as the outputs produced by a single example input dataset. It does not show how the validity and content of the generated output depends on the input dataset. While inputs are shown to be a directory containing STAC metadata, only inspection of the source code can establish whether the STAC is actually processed.

Furthermore, the demonstration purely evaluates the adherence of the software to the interoperability best practice and makes no attempt to judge the scientific validity of the data products produced.