EnMAP-Box / enmap-box

EnMAP-Box source code repository. See https://enmap-box.readthedocs.io for documentation
GNU General Public License v3.0
39 stars 16 forks source link

Invalid STAC outputs #853

Open jakimowb opened 7 months ago

jakimowb commented 7 months ago

Some algorithms create *.stac.json files to describe raster image metadata. However, the produced stac content is not valid according to the STAC specification.

For example def test_singleBand(self) in tests/enmap-box/enmapboxprocessing/algorithm/test_StackRasterLayersAlgorithm.py create a test-outputs/TestSubsetRasterBandsAlgorithm/test_singleBand/stack.vrt.stac.json:

{
  "stac_extensions": [
    "https://stac-extensions.github.io/eo/v1.0.0/schema.json",
    "https://stac-extensions.github.io/timestamps/v1.1.0/schema.json"
  ],
  "properties": {
    "eo:bands": [
      {
        "name": "Red (665 nanometers)"
      },
      {
        "name": "Red (665 nanometers)"
      }
    ]
  }
}

Validatin this in https://staclint.com/ will produce the following errors: grafik

The following links may help to produce valid stack files:

https://github.com/stac-utils/pystac https://github.com/radiantearth/stac-spec/blob/master/best-practices.md https://github.com/stac-utils/stac-check

janzandr commented 7 months ago

We need to add some required "dummy" items to make it valid:

{
    "stac_extensions": [
        "https://stac-extensions.github.io/eo/v1.0.0/schema.json"
    ],
  "stac_version": "1.0.0",
  "type": "Collection",
  "id": "dummy",
  "description": "dummy",
  "license": "dummy",
  "extent": {
      "spatial":{"bbox": [[0,0,0,0]]},
      "temporal": {"interval": [["000-00-00T00:00:00Z","0000-00-00T00:00:00Z"]]}
  },
  "links": [],
  "properties": {
    "eo:bands": [
      {
        "name": "Red (665 nanometers)"
      },
      {
        "name": "Red (665 nanometers)"
      }
    ]
  }
}
jakimowb commented 7 months ago

PyStac https://pystac.readthedocs.io/en/stable/ could become an optional dependency of the EnMAP-Box. If installed, we support writing and reading of STAC file. This way we don't need to implement an own "writer" and ensure compatibility to the STAC specs.