@un-fao/visualization@0.1.0-review.1
    Preparing search index...

    SingleBandRasterLayer

    SingleBandRasterLayer renders one georeferenced, single-band GeoTIFF through deck.gl. The package owns source selection, preparation, tiling, portrayal, legend metadata, and GPU resources. The consumer owns the source bytes or URL, the surrounding viewport, authentication, CORS policy, and accessible UI.

    Start here helps choose a surface and layer. This guide starts with compatible STAC metadata, then explains direct files/COGs and custom styles. The complete SingleBandRasterLayer and SingleBandRasterLayerProps API and supporting imports remain available; their size is not the minimum configuration you must supply.

    Install the complete package peer set. The example needs only the two runtime imports shown below, not every exported type or a direct Luma import.

    Supply an Item URL whose selected single-band raster and compatible metadata provide the portrayal. The layer needs only id and tagged source for this case. The application supplies a sized surface and a camera covering the raster; the world view below is a starting view, not automatic fitting to data bounds.

    import {
    DataViewport,
    SingleBandRasterLayer,
    } from '@un-fao/visualization';

    export function StacRaster({ itemUrl }: { itemUrl: string }) {
    const layer = new SingleBandRasterLayer({
    id: 'stac-raster',
    source: { type: 'stac-item-url', url: itemUrl },
    });

    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 Provides the standalone deck.gl surface used by this example.
    @un-fao/visualization SingleBandRasterLayer Runtime-required Creates the public layer that resolves and renders the selected raster.

    No callback, custom palette or explicit assetKey/renderKey is needed merely to try compatible metadata. If metadata is absent, unsupported or selects a different asset than intended, use the source choices and portrayal rules below. renderKey: 'default' is not a universal setting: requesting a nonexistent Render key can fail resolution.

    For a basemap, pass the same layer in layers to DataOverlay inside your map instead. Neither host supplies remote asset access or creates a legend UI for you.

    Static documentation validation compiles this example against the selected package. It does not execute WebGL or claim that a rendered pixel was inspected; rendering, shader, Worker, and GPU cleanup remain package-test responsibilities.

    File extends Blob. Use the tagged form when bytes need a diagnostic name. This is a layer factory, not a complete React component: put its returned layer in the surface's layers array as above. The 0–100 range is illustrative; use an increasing finite range appropriate to your actual sample values.

    import { SingleBandRasterLayer } from '@un-fao/visualization';

    export function createBlobRaster(blob: Blob) {
    return new SingleBandRasterLayer({
    id: 'uploaded-raster',
    source: { type: 'file', file: blob, name: 'uploaded-raster.tif' },
    displayMin: 0,
    displayMax: 100,
    });
    }
    Module Import Purpose Why or when
    @un-fao/visualization SingleBandRasterLayer Runtime-required Creates a layer from bytes already supplied by the consumer.

    Without STAC or an authored style, a continuous file/COG needs an explicit display range and uses grayscale. Reading an asset directly also bypasses its STAC scale/offset, colors and units. A STAC range expressed in physical units is not automatically the right range for the raw samples in that same TIFF.

    The tagged forms require type plus their url, item or file field. Fields marked ? below are optional context, not required configuration.

    Input Detection and selection When to prefer it
    string .tif/.tiff selects a raster and .json/.geojson selects a STAC Item; other HTTP(S) URLs use response content type and STAC-like path hints before falling back to raster. Concise input when the URL form is unambiguous.
    URL Uses the same suffix, response, and path-hint detection as a string. When the caller already owns a URL object.
    Blob Read locally as GeoTIFF bytes. In-memory bytes with no filename.
    File Read locally as GeoTIFF bytes and retains its filename for diagnostics. Browser uploads and file pickers.
    StacItemLike Selects an eligible asset from the inline Item. Relative asset hrefs need an explicit base. When the consumer already fetched and validated the Item shape.
    { type: 'raster-url', url } Always treats the HTTP(S) value as a GeoTIFF URL. Avoids suffix/content ambiguity.
    { type: 'stac-item-url', url, baseUrl? } Fetches one STAC Item and resolves its selected asset. Remote STAC Item discovery with an explicit interpretation.
    { type: 'stac-item', item, baseUrl?, itemUrl?, assetKey?, renderKey? } Uses the supplied Item and optional selection/base context. Full control over inline STAC resolution.
    { type: 'file', file, name? } Reads the supplied Blob or File locally. Adds a diagnostic name to a plain Blob.

    Remote GeoTIFFs must be accessible to the browser and support byte-range requests. Both the catalogue and the asset need appropriate browser CORS access. The example takes a URL from the caller; it is not tied to a live repository or FAO endpoint. Its 0–1 domain is illustrative, not automatically inferred.

    import { SingleBandRasterLayer } from '@un-fao/visualization';

    export function createRemoteCogLayer(cogUrl: string) {
    return new SingleBandRasterLayer({
    id: 'remote-cog',
    source: { type: 'raster-url', url: cogUrl },
    displayMin: 0,
    displayMax: 1,
    });
    }
    Module Import Purpose Why or when
    @un-fao/visualization SingleBandRasterLayer Runtime-required Creates a layer from a caller-supplied remote COG URL.

    assetKey requests a particular asset and renderKey requests a Render entry. Use keys that actually exist on the selected Item. Leave both absent for automatic selection; inspect onSourceResolved if you need to confirm that it matches your intent. Layer-level keys override matching keys on an inline tagged source; prefer one location instead of configuring both.

    import { SingleBandRasterLayer } from '@un-fao/visualization';

    export function createStacUrlLayer(
    itemUrl: string,
    assetKey?: string,
    renderKey?: string,
    ) {
    return new SingleBandRasterLayer({
    id: 'stac-raster',
    source: { type: 'stac-item-url', url: itemUrl },
    ...(assetKey === undefined ? {} : { assetKey }),
    ...(renderKey === undefined ? {} : { renderKey }),
    });
    }
    Module Import Purpose Why or when
    @un-fao/visualization SingleBandRasterLayer Runtime-required Resolves a caller-supplied STAC Item URL and its selected raster asset.

    Relative asset hrefs require sourceBaseUrl, or baseUrl/itemUrl on the tagged source. hrefResolver may apply consumer authentication or proxy rules, but its final result must still be HTTP(S).

    It rewrites only the selected STAC raster asset. It does not proxy the Item request, configure CORS, or rewrite a direct raster-url source. The example proxy URL is a placeholder for a consumer-owned, access-controlled service; the demo's /__gcs proxy is not shipped by the package.

    import {
    SingleBandRasterLayer,
    type StacItemLike,
    } from '@un-fao/visualization';

    const item = {
    type: 'Feature',
    stac_version: '1.0.0',
    id: 'consumer-item',
    geometry: null,
    properties: {},
    assets: { data: { href: './consumer-raster.tif', type: 'image/tiff' } },
    } satisfies StacItemLike;

    export const inlineStacLayer = new SingleBandRasterLayer({
    id: 'inline-stac-raster',
    source: {
    type: 'stac-item',
    item,
    itemUrl: 'https://catalog.example.test/items/consumer-item.json',
    assetKey: 'data',
    },
    displayMin: 0,
    displayMax: 100,
    hrefResolver: (href) =>
    `https://proxy.example.test/cog?url=${encodeURIComponent(href)}`,
    });
    Module Import Purpose Why or when
    @un-fao/visualization SingleBandRasterLayer Runtime-required Creates a layer from the inline STAC Item.
    @un-fao/visualization StacItemLike Optional type-only Checks the consumer-authored Item shape without adding runtime JavaScript.

    Continuous rendering interpolates values across a palette or authored stops. The display-domain precedence is displayMin/displayMax props first, style.displayRange second, then compatible STAC Render or Raster metadata. A direct Blob, File, or COG without suitable metadata needs an explicit valid pair from the props or style. Values outside the domain are clamped, and stops outside it are reported as legend warnings.

    Use one range location for an ordinary example. Supply both top-level endpoints together; they must be finite and increasing, not combined one endpoint at a time with metadata. With an explicit continuous style, a partial or invalid prop pair is rejected. Use style.displayRange when the domain travels with a reusable style; a valid top-level pair overrides it. A legend title or unit only labels values, it does not transform samples.

    Field Required? Meaning
    kind: 'continuous' Required Selects continuous portrayal.
    displayRange Optional Supplies [min, max] when the prop pair is absent and overrides compatible STAC metadata.
    colors Optional Uses either a palette of RasterColor values or interpolated RasterColorStop entries.
    legend Optional Supplies a consumer title and unit; it does not create a display domain.
    import type { SingleBandContinuousRasterStyle } from '@un-fao/visualization';

    export const temperatureStyle = {
    kind: 'continuous',
    displayRange: [-20, 50],
    colors: {
    type: 'interpolate',
    stops: [
    { value: -20, color: '#313695', label: 'Cold' },
    { value: 15, color: '#ffffbf' },
    { value: 50, color: '#a50026', label: 'Hot' },
    ],
    },
    legend: { title: 'Temperature', unit: '°C' },
    } satisfies SingleBandContinuousRasterStyle;
    Module Import Purpose Why or when
    @un-fao/visualization SingleBandContinuousRasterStyle Optional type-only Checks the complete continuous portrayal without adding runtime JavaScript.

    Classified rendering performs exact integer lookup and uses nearest sampling. Each value must be within the inclusive exact-Float32 integer range -16,777,216 to 16,777,216. Independently, the inclusive lookup span maximum - minimum + 1 must not exceed 65,536; neither limit is a normal design target. Missing colors may use a grayscale fallback and produce a warning. A class marked nodata is transparent.

    Field Required? Meaning
    kind: 'classified' Required Selects exact-value classification.
    classes Optional Supplies RasterClassStyle rows; compatible STAC classification metadata may supply them when absent.
    classes[].value Required per row Exact integer matched by the shader lookup.
    classes[].name / title Optional Supplies human-readable class metadata.
    classes[].color Optional Accepts a supported RasterColor; absence may use grayscale with a warning.
    classes[].nodata Optional Makes the class transparent when true.
    legend Optional Supplies a title or unit for the derived class legend.
    import type { SingleBandClassifiedRasterStyle } from '@un-fao/visualization';

    export const landCoverStyle = {
    kind: 'classified',
    classes: [
    { value: 0, title: 'No data', nodata: true },
    { value: 1, title: 'Water', color: '#2b83ba' },
    { value: 2, title: 'Vegetation', color: '#1a9850' },
    ],
    legend: { title: 'Land cover' },
    } satisfies SingleBandClassifiedRasterStyle;
    Module Import Purpose Why or when
    @un-fao/visualization SingleBandClassifiedRasterStyle Optional type-only Checks exact-value classes and their colors without adding runtime JavaScript.

    Interval quantities must be finite, strictly increasing after Float32 normalization, and use six-digit hexadecimal colors. opacity and label are optional; opacity is between 0 and 1. Each quantity is an exclusive upper bound: the first item covers values below its quantity and later items cover [previous quantity, quantity). Values at or above the final quantity are not drawn. Display bounds do not redefine interval thresholds, and interval rendering uses nearest sampling. Large interval resources can fail during GPU resource creation and are reported through onError.

    Field Required? Meaning
    kind: 'intervals' Required Selects ordered interval portrayal.
    items Optional Supplies RasterIntervalStyleItem rows; compatible STAC Render intervals may supply them when absent.
    items[].quantity Required per row Exclusive upper bound after Float32 normalization.
    items[].color Required per row Six-digit #RRGGBB color.
    items[].opacity Optional Alpha from 0 to 1; defaults to 1 for an authored row.
    items[].label Optional Non-empty consumer label; otherwise the legend derives a range label.
    legend Optional Supplies a title or unit for the interval legend.
    import type { SingleBandIntervalRasterStyle } from '@un-fao/visualization';

    export const rainfallStyle = {
    kind: 'intervals',
    items: [
    { quantity: 10, color: '#ffffcc', label: 'Low' },
    { quantity: 50, color: '#41b6c4', opacity: 0.9, label: 'Medium' },
    { quantity: 100, color: '#253494', label: 'High' },
    ],
    legend: { title: 'Rainfall', unit: 'mm' },
    } satisfies SingleBandIntervalRasterStyle;
    Module Import Purpose Why or when
    @un-fao/visualization SingleBandIntervalRasterStyle Optional type-only Checks ordered thresholds and their display metadata without adding runtime JavaScript.

    These three examples are complete public configurations. Source-backed portrayal is different: compatible selected STAC metadata may provide the domain, classes, intervals, colors, unit, nodata, scale/offset, or resampling. Warnings and unsupported requirements describe what was accepted or rejected; they are not proof that rendering completed.

    Prop Type Required? Default Ownership and effect
    source SingleBandRasterSourceInput Required No package default Raster-owned. Selects the only raster source and must always be supplied.
    assetKey string Optional No package default Raster-owned. Selects one STAC asset when supplied outside a tagged source.
    renderKey string Optional No package default Raster-owned. Selects one STAC Render definition when supplied outside a tagged source.
    sourceBaseUrl string Optional No package default Raster-owned. Resolves relative hrefs for an inline STAC Item.
    hrefResolver (href: string, context: StacHrefContext) => string Optional No package default Raster-owned. Lets the consumer rewrite a selected href to a final HTTP(S) URL.
    Prop Type Required? Default Ownership and effect
    displayMin number Optional No package default Raster-owned. With displayMax, overrides the continuous display domain after source scale/offset.
    displayMax number Optional No package default Raster-owned. With displayMin, must form a finite increasing continuous domain.
    style SingleBandRasterStyle Optional No package default Raster-owned. Chooses continuous, classified, or interval portrayal; compatible source metadata may be used when absent.
    nodata number Optional No package default Raster-owned. Explicit usable nodata overrides source metadata and makes matching samples transparent.
    resampling RasterResampling Optional Derived by portrayal Raster-owned. May be caller- or source-selected; continuous falls back to auto, while classified and interval resolve to nearest.
    Prop Type Required? Default Ownership and effect
    tileSize number Optional 512 Raster-owned. Changes tile dimensions and therefore memory, request, and GPU workload.
    maxRequests number Optional 8 Raster-owned. Bounds concurrent tile reads; increasing it trades latency for bandwidth and memory pressure.
    maxCacheByteSize number Optional No package default Raster-owned. Applies a byte budget only when supplied; choose it from measured workloads.
    debounceTime number Optional 250 ms Raster-owned. Delays viewport-driven tile updates to reduce churn during interaction.
    Prop Type Required? Default Ownership and effect
    onSourceResolved (intent: RasterSourceIntent) => void Optional No package default Raster-owned. Reports selected source identity, STAC context, portrayal metadata, warnings, and unsupported requirements.
    onLegendResolved (legend: RasterLegendInfo | null) => void Optional No package default Raster-owned. Reports display-ready legend metadata or null when no usable legend is ready or the layer is cleared.
    onLoad (info: SingleBandRasterLoadInfo) => void Optional No package default Raster-owned. Reports prepared bounds, effective nodata, and the continuous display domain when applicable.
    onError ((error: Error) => boolean | void) | null Optional No package default Inherited from deck.gl Layer. Receives source, portrayal, resource, or tile failures through deck.gl's error-handler contract.

    All other generic layer props belong to deck.gl. Consult the exact Layer API for upstream behavior and defaults rather than assuming the Visualization package owns them.

    onSourceResolved describes resolution intent, not a successful draw. onLoad describes a prepared source. onLegendResolved describes the legend that a consumer may present and can receive null; no callback ordering or frequency beyond these meanings is promised. onError is the failure path.

    These callbacks are optional observations, not required configuration. A legend callback returns data for your own accessible UI; it does not create a widget. Clear stale legend UI when it receives null. A prepared source can still fail during later tile reads, decoding or rendering.

    Callback What it establishes Important boundary
    onSourceResolved Source identity, selected STAC context, render metadata, warnings, and unsupported requirements. Resolution is not a successful draw.
    onLoad Prepared geographic bounds, effective nodata, and continuous domain when applicable. Classified and interval domains are reported as null.
    onLegendResolved Display-ready continuous, classified, or interval legend metadata. null means no usable legend is ready or the layer was cleared.
    onError Source, portrayal, resource, or tile failure. Handling behavior follows the upstream deck.gl callback contract.

    RasterLegendInfo is discriminated by kind: continuous legends contain a gradient and ticks, classified legends contain exact-value items, and interval legends contain lower/upper bounds. Their sources fields explain whether domain, colors, classes, or units came from props, style, or STAC metadata. Warnings should be surfaced or handled by the consumer.

    • EPSG:4326 source reading and tile placement have direct tile-test coverage.
    • EPSG:3857 source handling is provisional; this guide does not claim complete end-to-end placement proof for it.
    • Mercator and Globe view behavior are supported at the tileset and real-GPU sublayer seams, not by static documentation compilation.
    • Sources must be georeferenced and single-band. Remote sources must be range-readable, and their servers must expose suitable browser CORS headers.
    • Credentials, signed URLs, authentication refresh, proxying, and hrefResolver policy remain consumer responsibilities.

    tileSize, maxRequests, maxCacheByteSize, and debounceTime trade memory, latency, bandwidth, interaction responsiveness, and GPU work. Keep their defaults unless measurements from the target dataset and device justify a change. There is no universal cache budget, and internal cache/debug APIs and benchmark thresholds are not part of the public package contract.

    Symptom Check first
    Missing display-domain error For continuous portrayal, supply a complete finite increasing range or suitable metadata. Direct COG/File input does not infer a range.
    Requested Render key is missing Omit renderKey for automatic selection or use a real key from that Item; default is not universal.
    Catalogue loads but the raster does not Check raster CORS, range support and authorization separately from Item access.
    Raster is blank without an obvious error Container size, view bounds, source/portrayal warnings, onError, and nodata/transparent values. Source onLoad is not a visible-tile guarantee.
    Colors/units differ when using the TIFF directly Direct input bypasses STAC scale/offset and portrayal. Choose a raw-sample range and deliberate style, or keep the STAC input.
    Legend does not appear Render the callback's data in your own UI; no built-in legend control is mounted.

    This table is generated from the reviewed public API inventory. Import only the symbols your application uses.

    Export Form Canonical package import
    ClassifiedRasterLegendInfo Type-only import type { ClassifiedRasterLegendInfo } from '@un-fao/visualization';
    ContinuousRasterLegendInfo Type-only import type { ContinuousRasterLegendInfo } from '@un-fao/visualization';
    IntervalRasterLegendInfo Type-only import type { IntervalRasterLegendInfo } from '@un-fao/visualization';
    RasterClassStyle Type-only import type { RasterClassStyle } from '@un-fao/visualization';
    RasterColor Type-only import type { RasterColor } from '@un-fao/visualization';
    RasterColorStop Type-only import type { RasterColorStop } from '@un-fao/visualization';
    RasterContinuousColorRamp Type-only import type { RasterContinuousColorRamp } from '@un-fao/visualization';
    RasterIntervalStyleItem Type-only import type { RasterIntervalStyleItem } from '@un-fao/visualization';
    RasterLegendClassColorSource Type-only import type { RasterLegendClassColorSource } from '@un-fao/visualization';
    RasterLegendClassItem Type-only import type { RasterLegendClassItem } from '@un-fao/visualization';
    RasterLegendClassSource Type-only import type { RasterLegendClassSource } from '@un-fao/visualization';
    RasterLegendColorStop Type-only import type { RasterLegendColorStop } from '@un-fao/visualization';
    RasterLegendContinuousColorSource Type-only import type { RasterLegendContinuousColorSource } from '@un-fao/visualization';
    RasterLegendInfo Type-only import type { RasterLegendInfo } from '@un-fao/visualization';
    RasterLegendIntervalItem Type-only import type { RasterLegendIntervalItem } from '@un-fao/visualization';
    RasterLegendOptions Type-only import type { RasterLegendOptions } from '@un-fao/visualization';
    RasterLegendTick Type-only import type { RasterLegendTick } from '@un-fao/visualization';
    RasterLegendUnitSource Type-only import type { RasterLegendUnitSource } from '@un-fao/visualization';
    RasterLegendValueDomainSource Type-only import type { RasterLegendValueDomainSource } from '@un-fao/visualization';
    RasterLegendWarning Type-only import type { RasterLegendWarning } from '@un-fao/visualization';
    RasterLegendWarningCode Type-only import type { RasterLegendWarningCode } from '@un-fao/visualization';
    RasterRenderRequirement Type-only import type { RasterRenderRequirement } from '@un-fao/visualization';
    RasterResampling Type-only import type { RasterResampling } from '@un-fao/visualization';
    RasterResolvedSource Type-only import type { RasterResolvedSource } from '@un-fao/visualization';
    RasterSourceIntent Type-only import type { RasterSourceIntent } from '@un-fao/visualization';
    RasterSourceWarning Type-only import type { RasterSourceWarning } from '@un-fao/visualization';
    SingleBandClassifiedRasterStyle Type-only import type { SingleBandClassifiedRasterStyle } from '@un-fao/visualization';
    SingleBandContinuousRasterStyle Type-only import type { SingleBandContinuousRasterStyle } from '@un-fao/visualization';
    SingleBandIntervalRasterStyle Type-only import type { SingleBandIntervalRasterStyle } from '@un-fao/visualization';
    SingleBandRasterLayer Runtime value import { SingleBandRasterLayer } from '@un-fao/visualization';
    SingleBandRasterLayerProps Type-only import type { SingleBandRasterLayerProps } from '@un-fao/visualization';
    SingleBandRasterLoadInfo Type-only import type { SingleBandRasterLoadInfo } from '@un-fao/visualization';
    SingleBandRasterSourceInput Type-only import type { SingleBandRasterSourceInput } from '@un-fao/visualization';
    SingleBandRasterStyle Type-only import type { SingleBandRasterStyle } from '@un-fao/visualization';
    StacHrefContext Type-only import type { StacHrefContext } from '@un-fao/visualization';
    StacItemLike Type-only import type { StacItemLike } from '@un-fao/visualization';