SingleBandRasterCollectionLayer discovers a bounded STAC collection,
publishes a deterministic inventory, selects one metadata-eligible entry, and
delegates that entry to SingleBandRasterLayer. Consumers own the catalogue
input, selection state, remote access policy, and surrounding user interface.
Start with the small example below. Selection controls, custom portrayal and discovery limits are additional capabilities, not mandatory configuration. Start here explains the components; the full SingleBandRasterCollectionLayer, SingleBandRasterCollectionLayerProps and supporting imports remain available.
Install the complete package peer set. Installed peers are distinct from the two runtime imports used here.
Supply a browser-accessible Collection URL with supported item links and
compatible single-band portrayal metadata. No itemsUrl, forced range, selector
or callback is needed for this basic path. Discovery is bounded; the layer
selects one metadata-eligible entry rather than drawing all items or creating a
timeline. Frame the camera over your data; this example starts at a world view.
import { DataViewport, SingleBandRasterCollectionLayer } from '@un-fao/visualization';
export function CollectionRaster({ collectionUrl }: { collectionUrl: string }) {
const layer = new SingleBandRasterCollectionLayer({
id: 'collection-raster',
source: { type: 'stac-collection-url', url: collectionUrl },
});
return (
<div style={{ height: 480, position: 'relative', width: '100%' }}>
<DataViewport
controller
initialViewState={{ longitude: 0, latitude: 0, zoom: 2 }}
layers={[layer]}
/>
</div>
);
}
| Module | Import | Purpose | Why or when |
|---|---|---|---|
@un-fao/visualization |
DataViewport |
Runtime-required | Supplies the standalone drawing surface for this example. |
@un-fao/visualization |
SingleBandRasterCollectionLayer |
Runtime-required | Discovers the collection and attempts to render one selected raster. |
For a basemap, pass the layer to DataOverlay inside your map. If a catalogue does not provide supported links, use the explicit source forms below. Missing portrayal metadata may require a range or style; a public catalogue does not establish browser access to the raster assets.
This advanced example adds a consumer-owned selector and explicit display range. The example is deterministic: documentation checks compile it but do not fetch the reserved example URLs or start WebGL. The explicit display domain makes both entries eligible for a continuous single-band render attempt without assuming STAC portrayal metadata.
import { useMemo, useState } from 'react';
import {
DataViewport,
SingleBandRasterCollectionLayer,
type RasterCollectionEntry,
type StacItemCollectionLike,
} from '@un-fao/visualization';
const itemCollection = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
stac_version: '1.0.0',
id: 'temperature-2024-01',
geometry: null,
properties: { datetime: '2024-01-01T00:00:00Z' },
assets: {
data: { href: './temperature-2024-01.tif', type: 'image/tiff' },
},
},
{
type: 'Feature',
stac_version: '1.0.0',
id: 'temperature-2024-02',
geometry: null,
properties: { datetime: '2024-02-01T00:00:00Z' },
assets: {
data: { href: './temperature-2024-02.tif', type: 'image/tiff' },
},
},
],
} satisfies StacItemCollectionLike;
export function TemperatureCollection() {
const [entries, setEntries] = useState<readonly RasterCollectionEntry[]>([]);
const [selectedEntryId, setSelectedEntryId] = useState<string>();
const layer = useMemo(() => new SingleBandRasterCollectionLayer({
id: 'temperature-collection',
source: {
type: 'stac-item-collection',
itemCollection,
baseUrl: 'https://assets.example.test/collections/temperature/',
},
...(selectedEntryId ? { selectedEntryId } : {}),
displayMin: -20,
displayMax: 50,
onCollectionResolved: (info) => {
setEntries(info.entries);
setSelectedEntryId((current) => current ?? info.entries[0]?.id);
},
onSelectionResolved: ({ status, issues }) => {
console.info('selection', status, issues);
},
onLegendResolved: (legend) => {
if (legend) console.info('legend', legend.kind);
},
onLoad: (info) => {
console.info('loaded bounds', info.geographicBounds);
},
onError: (error) => {
console.error(error);
return true;
},
}), [selectedEntryId]);
return (
<div>
<label>
Raster entry
<select
value={selectedEntryId ?? ''}
onChange={(event) => setSelectedEntryId(event.currentTarget.value)}
>
{entries.map((entry) => (
<option key={entry.id} value={entry.id}>
{entry.itemId}{entry.datetime ? ` (${entry.datetime})` : ''}
</option>
))}
</select>
</label>
<div style={{ height: 480, position: 'relative', width: '100%' }}>
<DataViewport
controller
initialViewState={{ longitude: 0, latitude: 0, zoom: 2 }}
layers={[layer]}
/>
</div>
</div>
);
}
| Module | Import | Purpose | Why or when |
|---|---|---|---|
react |
useMemo |
Runtime-required | Keeps the deck.gl layer instance stable until the selected entry changes. |
react |
useState |
Runtime-required | Stores the public inventory and opaque selected entry ID used by the control. |
@un-fao/visualization |
DataViewport |
Runtime-required | Provides the standalone deck.gl surface used by this example. |
@un-fao/visualization |
SingleBandRasterCollectionLayer |
Runtime-required | Discovers, selects, and renders one raster entry from the collection. |
@un-fao/visualization |
RasterCollectionEntry |
Optional type-only | Types the callback-provided entries retained by the consumer control. |
@un-fao/visualization |
StacItemCollectionLike |
Optional type-only | Checks the authored ItemCollection shape without adding runtime JavaScript. |
Use the entry.id published by onCollectionResolved; it is intentionally
opaque. Do not reconstruct it from item IDs, dates, URLs, or indexes.
Collections can contain scenarios with the same dates, not just a time series.
Use labels that distinguish the entries in your data; an Item ID alone may also
need disambiguation when duplicates are present. Selection controls belong to
the application, not the package.
Each tagged source requires type and its named collection, itemCollection
or url payload. Base URLs and itemsUrl are optional unless relative links or
missing/unsuitable discovery links make them necessary for that source.
| Source form | Catalogue and asset base | Discovery behavior |
|---|---|---|
stac-item-collection |
itemCollection is inline; baseUrl resolves relative item assets. |
Uses the supplied features without a catalogue request. |
stac-item-collection-url |
url identifies the ItemCollection page; baseUrl only resolves that URL when it is relative. The fetched response URL resolves relative page links and item assets. |
Follows supported next-page links within configured bounds. |
stac-collection |
collection is inline; optional itemsUrl identifies the first item page and baseUrl resolves relative links. |
Uses an explicit items URL, a supported rel="items" link, or static rel="item" links. |
stac-collection-url |
url identifies the Collection document; optional itemsUrl overrides item discovery. |
Fetches the Collection, then uses the same supported item discovery paths. |
import { SingleBandRasterCollectionLayer } from '@un-fao/visualization';
export function itemCollectionUrlLayer(itemCollectionUrl: string) {
return new SingleBandRasterCollectionLayer({
id: 'remote-item-collection',
source: {
type: 'stac-item-collection-url',
url: itemCollectionUrl,
},
displayMin: 0,
displayMax: 100,
});
}
| Module | Import | Purpose | Why or when |
|---|---|---|---|
@un-fao/visualization |
SingleBandRasterCollectionLayer |
Runtime-required | Creates a collection layer from a caller-supplied ItemCollection URL. |
Supply source.baseUrl only when source.url itself is relative. It does not
redirect relative asset hrefs returned by a fetched ItemCollection. The fetched
page URL remains their base. To deliberately override relative asset resolution
for the selected raster, set the layer-level sourceBaseUrl; use
hrefResolver when the application needs a proxy or authentication rewrite.
import {
SingleBandRasterCollectionLayer,
type StacCollectionLike,
} from '@un-fao/visualization';
export function inlineCollectionLayer(
collection: StacCollectionLike,
itemsUrl: string,
) {
return new SingleBandRasterCollectionLayer({
id: 'inline-collection',
source: {
type: 'stac-collection',
collection,
baseUrl: 'https://catalog.example.test/',
itemsUrl,
},
displayMin: 0,
displayMax: 100,
});
}
| Module | Import | Purpose | Why or when |
|---|---|---|---|
@un-fao/visualization |
SingleBandRasterCollectionLayer |
Runtime-required | Creates the public collection layer from an inline Collection. |
@un-fao/visualization |
StacCollectionLike |
Optional type-only | Types the caller-validated inline Collection shape. |
Collection discovery does not recursively traverse child or catalog links
and does not provide provider-specific query adapters. Keep the Collection
document URL, item-page URL, and relative-asset base distinct.
onCollectionResolved publishes a RasterCollectionInfo snapshot. Its
entries contain deterministic public IDs and temporal ordering; duplicate
item IDs or temporal values remain addressable and are accompanied by issues.
entryCount, renderableCount, and unsupportedCount describe the current
snapshot. itemCountHint is provider metadata and may disagree with discovered
data. discoveryComplete, canLoadMore, loadingMore, resolved limits,
temporal extent, and issues describe whether the snapshot is complete and how
it was obtained.
Treat every snapshot as replaceable. Store a published entry.id for ongoing
selection, not a private key or a position inferred from a previous snapshot.
Prefer selectedEntryId from the current public inventory. A
selectedEntryIndex addresses only the current sorted snapshot and can move
when continued discovery changes ordering. If both are supplied, the ID wins.
If neither is supplied, the layer retains the first metadata-eligible entry it
selects.
Selection status is one of:
| Status | Meaning |
|---|---|
empty |
The current inventory contains no selectable entry. |
renderable |
The selected entry is metadata-eligible for an attempt; rendering is not yet proven. |
unsupported |
The selected entry has known unsupported metadata requirements. |
missing |
The requested public ID or current-snapshot index was not found. |
Discovery defaults to pageSize: 100, maxItems: 500, maxPages: 20, and
limitPolicy: "stop-with-warning". This policy preserves a discovered prefix,
reports the bound, and exposes incomplete state. When canLoadMore is true,
raise maxItems and/or maxPages; there is no imperative loadMore method.
Use limitPolicy: "error" only when exceeding an item or page cap must discard
the inventory. It is not a transaction across every transport or discovery
failure. A failed initial page has no prefix. A later fetch or JSON failure may
preserve the successful prefix with discoveryComplete: false; a pagination
loop is a hard failure, and an unsupported next link can leave an incomplete
prefix. Never present a retained prefix as a complete catalogue.
RasterCollectionSupportStatus uses the value "renderable" for an entry that
passes the current metadata preflight. It does not prove browser reachability,
authentication, CORS, range support, valid GeoTIFF bytes, CRS or band support,
tile reads, shader execution, or a visible GPU result. Those are later
selected-raster outcomes.
| Callback | Responsibility |
|---|---|
| onCollectionResolved | Current inventory, resolved limits, continuation state, and collection-wide issues. |
| onSelectionResolved | Current selection status, selected entry, selection issues, and source intent when available. |
| onLegendResolved | Legend metadata from the selected inner raster. |
| onLoad | Prepared-source information from the selected inner raster, not proof that visible tiles finished rendering. |
| onError | Unexpected rejected collection work and selected-raster source, resource, or tile failures. |
Expected invalid collection, fetch, JSON, link, item, limit, and selection
outcomes are reported through collection or selection issues; they are not
promised through onError. RasterCollectionIssueCode is versioned. Branch on
its code and severity rather than parsing message text. Do not rely on callback
order, count, or frame timing.
Use the guards to narrow an unknown value before passing it to a collection
source:
import {
isStacCollectionLike,
isStacItemCollectionLike,
type StacCollectionLike,
type StacItemCollectionLike,
} from '@un-fao/visualization';
export function narrowCollection(value: unknown): StacCollectionLike | null {
return isStacCollectionLike(value) ? value : null;
}
export function narrowItemCollection(
value: unknown,
): StacItemCollectionLike | null {
return isStacItemCollectionLike(value) ? value : null;
}
| Module | Import | Purpose | Why or when |
|---|---|---|---|
@un-fao/visualization |
isStacCollectionLike |
Runtime-required | Narrows an unknown value to the package's shallow Collection shape. |
@un-fao/visualization |
isStacItemCollectionLike |
Runtime-required | Narrows an unknown value to the package's shallow ItemCollection shape. |
@un-fao/visualization |
StacCollectionLike |
Optional type-only | Names the narrowed Collection result without adding runtime JavaScript. |
@un-fao/visualization |
StacItemCollectionLike |
Optional type-only | Names the narrowed ItemCollection result without adding runtime JavaScript. |
isStacCollectionLike requires an object with type: "Collection", STAC major
version 1, non-empty id, description, and license, spatial and temporal
extent arrays, and a links array. isStacItemCollectionLike requires a
FeatureCollection with a features array; every item must be a Feature with
string stac_version and id, object properties and assets, and the outer
links value must be an array when present. The ItemCollection guard does not
require a non-empty item ID or item STAC major version 1.
These guards are narrowing helpers, not JSON Schema or STAC conformance validators. They do not fetch links, validate link methods or media types, prove asset or render metadata, inspect GeoTIFF/COG bytes, verify CRS, bands, or byte ranges, establish CORS or authentication, or prove rendering.
| Prop | Type | Required? | Default | Ownership and effect |
|---|---|---|---|---|
source |
RasterCollectionSourceInput |
Required | No package default | Collection-owned. Supplies one of the four supported collection inputs. |
selectedEntryId |
string |
Optional | No package default | Collection-owned. Selects an opaque public entry ID and wins over index; omission derives the first metadata-eligible entry. |
selectedEntryIndex |
number |
Optional | No package default | Collection-owned. Selects a position only within a fixed sorted snapshot; omission derives the first metadata-eligible entry. |
assetKey |
string |
Optional | No package default | Selected-raster. Requests one STAC asset for the selected item. |
renderKey |
string |
Optional | No package default | Selected-raster. Requests one STAC Render definition for the selected item. |
sourceBaseUrl |
string |
Optional | No package default | Selected-raster. Resolves relative selected-item asset references. |
hrefResolver |
(href: string, context: StacHrefContext) => string |
Optional | No package default | Selected-raster. Applies caller proxy or authentication URL policy. |
| Prop | Type | Required? | Default | Ownership and effect |
|---|---|---|---|---|
pageSize |
number |
Optional | 100 |
Collection-owned. Requests this many candidates per supported item page. |
maxItems |
number |
Optional | 500 |
Collection-owned. Bounds discovered item candidates and can be raised to continue. |
maxPages |
number |
Optional | 20 |
Collection-owned. Bounds fetched item pages and can be raised to continue. |
limitPolicy |
RasterCollectionLimitPolicy |
Optional | stop-with-warning |
Collection-owned. Chooses prefix preservation or strict cap failure. |
| Prop | Type | Required? | Default | Ownership and effect |
|---|---|---|---|---|
displayMin |
number |
Optional | No package default | Selected-raster. Sets the lower display bound before style or STAC metadata. |
displayMax |
number |
Optional | No package default | Selected-raster. Sets the upper display bound before style or STAC metadata. |
style |
SingleBandRasterStyle |
Optional | No package default | Selected-raster. Controls continuous, classified, or interval portrayal. |
nodata |
number |
Optional | No package default | Selected-raster. Overrides nodata metadata for masking. |
resampling |
RasterResampling |
Optional | Derived by portrayal | Selected-raster. Uses portrayal-compatible nearest or linear sampling. |
| Prop | Type | Required? | Default | Ownership and effect |
|---|---|---|---|---|
tileSize |
number |
Optional | 512 |
Selected-raster. Sets the selected inner layer's tile resolution. |
maxRequests |
number |
Optional | 8 |
Selected-raster. Bounds concurrent selected-raster tile reads. |
maxCacheByteSize |
number |
Optional | No package default | Selected-raster. Applies an optional byte ceiling to the tile cache. |
debounceTime |
number |
Optional | 250 ms |
Selected-raster. Delays viewport-driven tile refinement. |
| Prop | Type | Required? | Default | Ownership and effect |
|---|---|---|---|---|
onCollectionResolved |
(info: RasterCollectionInfo) => void |
Optional | No package default | Collection-owned. Publishes current collection inventory and diagnostics. |
onSelectionResolved |
(selection: RasterCollectionSelection) => void |
Optional | No package default | Collection-owned. Publishes the current selection outcome and issues. |
onLegendResolved |
(legend: RasterLegendInfo | null) => void |
Optional | No package default | Selected-raster. Publishes the selected raster's legend metadata. |
onLoad |
(info: SingleBandRasterLoadInfo) => void |
Optional | No package default | Selected-raster. Reports prepared bounds and effective source settings; later tile reads can still fail. |
onError |
((error: Error) => boolean | void) | null |
Optional | No package default | Inherited from deck.gl Layer. Handles unexpected layer and resource failures. |
Generic deck.gl layer properties remain upstream-owned. See the deck.gl Layer API for those properties. Source, portrayal, legend, projection, resources, and GPU lifecycle details are documented once in the SingleBandRasterLayer guide.
The collection layer passes selected-raster source and portrayal props to its
inner SingleBandRasterLayer. Use the single-raster guide for display-domain
precedence, style modes, legends, nodata, resampling, projection, and resource
constraints. Collection eligibility does not replace those checks.
Use one range location per example: the top-level displayMin/displayMax
pair, or style.displayRange in a reusable continuous style. Valid top-level
values win; supplying only half a pair is not a way to override one endpoint.
See continuous portrayal.
Legend and selection records are outputs, not objects to pass back as style.
Caller-provided catalogue and raster URLs must be browser-reachable and use an appropriate CORS and authentication policy. Selected remote rasters must also meet the byte-range and source constraints in the single-raster guide. The package does not embed credentials or proxy provider-specific requests.
hrefResolver rewrites the selected STAC raster asset only. It does not proxy
Collection/Item/page requests or enable CORS. The demo's /__gcs proxy is not
part of the package. A consumer-owned proxy must enforce its own access policy;
do not disable browser security to make an example work.
| Symptom | Check first |
|---|---|
| No entries or a partial list | Collection/selection issues, source kind, supported item links and discoveryComplete; a prefix is not the full catalogue. |
| Loading stops at a limit | canLoadMore and the discovery caps; increasing maxRequests only changes tile concurrency, not discovery. |
| Wrong entry after more discovery | Store the callback's opaque entry ID, not a previous index or just a date. |
renderable but no raster |
Asset access/CORS, range responses, source/portrayal errors, container and camera bounds. Metadata eligibility is not a completed draw. |
| No legend UI | onLegendResolved supplies data; render your own accessible legend and clear it when the callback receives null. |
| Different colors after bypassing STAC | A direct COG loses STAC-only range, scale/offset, palette and units; raw-sample ranges are not automatically physical-unit ranges. |
Documentation CI compiles every example against the selected package and
checks navigation, imports, export ownership, prop metadata, defaults, and the
proof manifest. It performs no network or GPU work. Package tests cover the
public guards, collection discovery and callback seams, and selected-raster
rendering separately. There is currently no browser or real-GPU integration
test that exercises SingleBandRasterCollectionLayer as a whole.
This table is generated from the reviewed public API inventory. Import only the symbols your application uses.
| Export | Form | Canonical package import |
|---|---|---|
isStacCollectionLike |
Runtime value | import { isStacCollectionLike } from '@un-fao/visualization'; |
isStacItemCollectionLike |
Runtime value | import { isStacItemCollectionLike } from '@un-fao/visualization'; |
RasterCollectionEntry |
Type-only | import type { RasterCollectionEntry } from '@un-fao/visualization'; |
RasterCollectionInfo |
Type-only | import type { RasterCollectionInfo } from '@un-fao/visualization'; |
RasterCollectionIssue |
Type-only | import type { RasterCollectionIssue } from '@un-fao/visualization'; |
RasterCollectionIssueCode |
Type-only | import type { RasterCollectionIssueCode } from '@un-fao/visualization'; |
RasterCollectionLimitPolicy |
Type-only | import type { RasterCollectionLimitPolicy } from '@un-fao/visualization'; |
RasterCollectionSelection |
Type-only | import type { RasterCollectionSelection } from '@un-fao/visualization'; |
RasterCollectionSourceInput |
Type-only | import type { RasterCollectionSourceInput } from '@un-fao/visualization'; |
RasterCollectionSupportStatus |
Type-only | import type { RasterCollectionSupportStatus } from '@un-fao/visualization'; |
SingleBandRasterCollectionLayer |
Runtime value | import { SingleBandRasterCollectionLayer } from '@un-fao/visualization'; |
SingleBandRasterCollectionLayerProps |
Type-only | import type { SingleBandRasterCollectionLayerProps } from '@un-fao/visualization'; |
StacCollectionLike |
Type-only | import type { StacCollectionLike } from '@un-fao/visualization'; |
StacItemCollectionLike |
Type-only | import type { StacItemCollectionLike } from '@un-fao/visualization'; |