Skip to content

Raster band selection, config legend classes and unscale (#357, #350) - #427

Merged
cboettig merged 1 commit into
mainfrom
fix/raster-band-config
Nov 3, 2026
Merged

cboettig merged 1 commit into
mainfrom
fix/raster-band-config

Conversation

@cboettig

@cboettig cboettig commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Closes #357. Closes #350.

Band selection (#357). A raster asset can set bidx (1-based) to pick the band of a multi-band COG. Without it, TiTiler refuses a multi-band source and every tile fails with a 500. The band's STAC nodata and classification:classes are now read from the chosen band rather than always band 1.

Legend classes on rasters (#350). Config legend_classes now replace the STAC classes on a raster, as they already did on vectors. They also build the TiTiler colormap, so a class left out renders transparent. A class whose value is the band's nodata is always left out, which removes fill classes such as NLCD 250 without any config. Colors may be given as #RRGGBB or STAC RRGGBB.

Unscale. When a band's STAC entry gives a scale other than 1 or an offset other than 0, the tile URL adds &unscale=true, so rescale and the legend are in real units. A config unscale: true|false overrides this. This was needed for the NOAA Coral Reef Watch COGs (int16 in hundredths of a degree) in bosl-high-seas. I checked against TiTiler: /cog/info reports scales: [0.01] for ssta-latest.tif, and a tile with unscale=true&rescale=-1,4 returns 200.

The two TiTiler URL builders (versioned and plain) are now one function, cogTileUrl. It warns on the console when an inline colormap makes the URL longer than 8,000 characters (an 832-class EVT colormap made 47 kB).

Migration. For a raster whose STAC declares a scale or offset, rescale is now read in real units. An app with such a layer must change its rescale or set "unscale": false when it bumps its pin. The bosl-high-seas session checked all 60 of that app's raster collections and none declares a scale or offset, so only its new CRW layers are affected.

The docs' raster options table now has rows for bidx, unscale and legend_classes.

Tests: nine new cases in test/dataset-catalog.test.js.

A raster asset can now set bidx to pick the band of a multi-band COG,
and the band's STAC nodata and classes are read from that band. Config
legend_classes now replace the STAC classes on a raster, as they do on
a vector, so a class can be left out of the colormap; a class whose
value is the band's nodata is always left out. When STAC gives a band
scale or offset, the tile URL asks TiTiler to unscale, so rescale and
the legend are in real units; config unscale overrides. The two tile
URL builders are now one function, which also accepts #-prefixed
colors and warns when an inline colormap makes the URL too long.
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 72.21% 9870 / 13668
🔵 Statements 72.19% 9872 / 13674
🔵 Functions 76.55% 369 / 482
🔵 Branches 85.1% 2394 / 2813
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
app/dataset-catalog.js 93.19% 86.53% 100% 93.19% 203-205, 227-229, 254-263, 283-285, 298-299, 571-576, 607-649, 733, 1051-1057
Generated in workflow #327 for commit 44f8f0a by the Vitest Coverage Report Action

@cboettig
cboettig merged commit 437bc96 into main Nov 3, 2026
2 checks passed
@cboettig
cboettig deleted the fix/raster-band-config branch November 3, 2026 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant