Skip to main content

Dataset discovery

@loaders.gl/ogc/stac

The STAC module discovers datasets, links, time ranges, and spatial extents from static catalogs or API searches, then leaves the selected asset free to use its native loader.

Catalog discovery

Find the asset before opening the bytes.

STAC narrows a dataset by space, time, collection, and links. Once an asset is selected, its native loaders.gl source can handle the actual data.

01

Catalog or API

collections · search

spacetime

02

STAC item

one spatiotemporal record

extentcontext

03

Asset link

role · media type · URL

chooseinspect

04

Native loader

Parquet · GeoTIFF · Zarr

decodescan

STAC describes where the data is and what it means; the format loader remains responsible for decoding it.

Discovery before decoding

Catalogs describe data. Assets carry it.

STAC keeps search and traversal separate from format parsing. Once an item and asset are selected, the application can hand the link to GeoTIFF, Parquet, COG, or another specialized loader.

Static

Traverse linked catalogs when explicitly requested

API

Search items by collection, time, or bbox

Asset

Select links by role, media type, or name

Next step

Load the asset with its native format module

From-v5.0

The @loaders.gl/ogc/stac module discovers datasets and assets described by the SpatioTemporal Asset Catalog specification. It supports both linked static catalogs and server-side STAC API Item Search without imposing a rendering framework or a database dependency.

Detailed guide

STAC source usage

The sections below cover installation, catalog traversal, API search, and asset selection.

Installation​

npm install @loaders.gl/core @loaders.gl/services

Usage​

import {createDataSource} from '@loaders.gl/core';
import {STACLoader} from '@loaders.gl/ogc/stac';

const source = await createDataSource('https://example.com/catalog.json', STACLoader);
const {mode, root} = await source.getMetadata();

if (mode === 'api') {
for await (const item of source.search({
collections: ['buildings'],
bbox: [-71.1, 42.3, -71.0, 42.4]
})) {
console.log(source.getAssets(item, {roles: ['data']}));
}
} else {
// Static catalogs are only crawled when the application explicitly opts in.
for await (const item of source.traverse({maxDepth: 4, maxRequests: 100})) {
console.log(item.id);
}
}

See STACLoader for the source API and STAC format notes for protocol behavior.

Browser access​

Catalog discovery does not guarantee that an asset can be read by a browser. A browser-native remote Parquet query requires the asset host to allow cross-origin requests, accept byte ranges, and expose headers such as Content-Range and Content-Length.

The source preserves all provider assets so the application can select an appropriate mirror. Probe the selected URL with a small range request and handle a rejected fetch separately from a server that returns the whole object instead of 206 Partial Content.