developmentseed / developmentseed/rio-stac
titiler `/cog/stac` endpoint: populate `eo:bands commonName` with description (red, green, blue)
- Dominant language
- Python
- Stars
- 94
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
## Background
Context: I'm trying to load a remote COG on a [kepler-gl/demo](https://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 https://github.com/developmentseed/titiler/pull/1038 from a COG via the endpoint [/cog/stac](https://titiler.xyz/api.html#/Cloud%20Optimized%20GeoTIFF/.cog.createSTAC) 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](https://github.com/keplergl/kepler.gl/blob/bc59e880bfc70f72f335defee8d427c15928df16/src/layers/src/raster-tile/config.ts#L141-L145), 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](https://github.com/stac-extensions/eo?tab=readme-ov-file#common-band-names)
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](https://github.com/developmentseed/geotiff-test-data/blob/main/real_data/hot-oam/68077a72c46a9912474701ef.tif): [titiler-stac item](https://titiler.xyz/cog/stac?asset_name=data&asset_media_type=auto&with_proj=true&with_raster=true&with_eo=true&max_size=1024&geometry_densify=0&geometry_precision=-1&url=https%3A%2F%2Fgithub.com%2Fdevelopmentseed%2Fgeotiff-test-data%2Fraw%2Frefs%2Fheads%2Fmain%2Freal_data%2Fhot-oam%2F68077a72c46a9912474701ef.tif)
Possible similar issue https://github.com/developmentseed/titiler/issues/29
```json
{
"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"
}
],
}
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.