Skip to content

titiler /cog/stac endpoint: populate eo:bands commonName with description (red, green, blue) #76

@jo-chemla

Description

@jo-chemla

Background

Context: I'm trying to load a remote COG on a kepler-gl/demo map app, which requires a STAC item json pointing to the COG in order to load it - for now I'm trying with a standard, 8-bits RGB COG.

The flow to add this COG is, within kepler demo app: Add Data -> Tileset -> Raster Tile, then

  • Tileset Metadata URL should point to the STAC item URL
  • and Raster-Tile Server should point to a live titiler endpoint, eg https://titiler.xyz

I realized titiler can create such a STAC after PR developmentseed/titiler#1038 from a COG via the endpoint /cog/stac which relies on rio-stac. So I tried to load the STAC generated by titiler given a COG url into kepler map, and unfortunately the user can only select one band preset, with colormap of choice, and not display the trueColor representation of the dataset.

Reason

At the moment, for 3 bands COG, the item eo:bands is generated by rio-stac, with b1, b2, b3 description: red, green, blue.

Unfortunately, for Keplergl to understand the COG is an RGB which can be represented as trueColor, it relies on the bands having the correct commonNames attribute - see kplergl trueColor definition, which expects commonNames: ['red', 'green', 'blue'] to be present in the item bands. Hence why for now the dataset can only be represented as preset: single-band, with either b1..b3 colormapped.

Do you think it could make sense, in addition for rio-stac to populating description with b1: red, b2: green, b3: blue, if the description name is actually a STAC spec common_name, to also populate that field? See the list of accepted common_name's

If so, I can try to do a quick PR to do so.

Example via a test-data COG sample from developmentseed/geotiff-test-data hot-oam: titiler-stac item

Possible similar issue developmentseed/titiler#29

{
  "type": "Feature",
  "stac_version": "1.1.0",
  "stac_extensions": [
    "https://stac-extensions.github.io/projection/v1.1.0/schema.json",
    "https://stac-extensions.github.io/raster/v1.1.0/schema.json",
    "https://stac-extensions.github.io/eo/v1.1.0/schema.json"
  ],
  "id": "cog.tif",
  // geometry, bbox, properties, links": [],
  "assets": {
    "data": {
      "href": "....tif",
      "type": "image/tiff; application=geotiff",
      "raster:bands": [
        {
          "data_type": "uint8",
          "scale": 1,
          "offset": 0,
          "sampling": "area",
          "statistics": { /* ... */ },
          "histogram": { /* ... */  }
        },
        // ...
      ],
      "eo:bands": [
        {
          "name": "b1",
          "description": "red"
        },
        {
          "name": "b2",
          "description": "green"
        },
        {
          "name": "b3",
          "description": "blue"
        }
      ],
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions