Raster, GeoTIFF and WebGL · Angular, React and OpenLayers
A Cloud Optimized GeoTIFF in a WebGL layer
Stream a Sentinel-2 Cloud Optimized GeoTIFF directly in OpenLayers WebGL using HTTP range reads, native UTM GeoKeys view setup and overzooming.

What this example shows
A true-colour Copernicus Sentinel-2 acquisition of Kraków from 14 August 2024—showing the winding Vistula, the Planty ring, Las Wolski forest and surrounding farmland—streams directly from a single Cloud Optimized GeoTIFF (TCI.tif) in a WebGL tile layer without any tile server.
When you need it
Modern earth-observation archives (AWS Registry of Open Data, Copernicus, Planetary Computer) store satellite scenes, drone orthomosaics and DEMs on plain S3/HTTP object storage as Cloud Optimized GeoTIFFs (COGs).
OpenLayers’ GeoTIFF source issues HTTP Range requests for only the internal TIFF tiles and overviews visible on screen—displaying multi-gigabyte rasters directly from static storage.
The code
The example uses cc-openlayers, my Angular component library for OpenLayers: each aol-… element creates the OpenLayers object it names, updates it from its inputs and disposes of it with the component.
cog.shared.tsimport type { Coordinate } from 'ol/coordinate.js';
import type { SourceInfo } from 'ol/source/GeoTIFF.js';
const SCENE =
'https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/34/U/DA/2024/8/S2B_34UDA_20240814_0_L2A';
/** The Main Market Square in the scene's projection, UTM zone 34N (EPSG:32634). */
export const KRAKOW: Coordinate = [423901, 5545999];
export const SOURCES: SourceInfo[] = [{ url: `${SCENE}/TCI.tif` }];cog.tsimport { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { DefaultControlComponent, DefaultInteractionComponent, MapComponent, ViewComponent } from 'cc-openlayers';
import { LayerWebGLTileComponent, SourceGeoTIFFComponent } from 'cc-openlayers/webgl';
import { withHigherResolutions, type ViewOptions } from 'ol/View';
import { KRAKOW, SOURCES } from './cog.shared';
/** The true-colour image of a Sentinel-2 scene over Kraków: one three-band COG, read tile by tile in its own projection. */
@Component({
selector: 'app-cog',
imports: [
DefaultControlComponent,
DefaultInteractionComponent,
LayerWebGLTileComponent,
MapComponent,
SourceGeoTIFFComponent,
ViewComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<aol-map height="480px">
<aol-interaction-default />
<aol-control-defaults />
@if (view(); as options) {
<aol-view
[projection]="options.projection"
[resolutions]="options.resolutions"
[extent]="options.extent"
[showFullExtent]="options.showFullExtent"
[center]="krakow"
[resolution]="20"
/>
}
<aol-layer-webgltile>
<aol-source-geotiff
[sources]="sources"
attributions="Contains modified Copernicus Sentinel data 2024"
(viewReady)="showScene($event)"
/>
</aol-layer-webgltile>
</aol-map>
`,
})
export class Cog {
readonly view = signal<ViewOptions | undefined>(undefined);
protected readonly krakow = KRAKOW;
protected readonly sources = SOURCES;
/** The view of the scene with one resolution finer than its 10 m pixels, to zoom in past them. */
protected showScene(view: ViewOptions): void {
this.view.set(withHigherResolutions(1)(view));
}
} The React version uses the library's React adapter, cc-openlayers/react: each component creates the OpenLayers object it names when it mounts, updates it from its props and disposes of it when it unmounts.
cog.react.tsximport { useState } from 'react';
import { withHigherResolutions, type ViewOptions } from 'ol/View.js';
import { DefaultControls, DefaultInteractions, Map, View } from 'cc-openlayers/react';
import { GeoTIFFSource, WebGLTileLayer } from 'cc-openlayers/react/webgl';
import { KRAKOW, SOURCES } from './cog.shared';
/** The true-colour image of a Sentinel-2 scene over Kraków: one three-band COG, read tile by tile in its own projection. */
export function Cog() {
const [options, setOptions] = useState<ViewOptions>();
/** The view of the scene with one resolution finer than its 10 m pixels, to zoom in past them. */
const showScene = (view: ViewOptions) => setOptions(withHigherResolutions(1)(view));
return (
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
{options && (
<View
projection={options.projection}
resolutions={options.resolutions}
extent={options.extent}
showFullExtent={options.showFullExtent}
center={KRAKOW}
resolution={20}
/>
)}
<WebGLTileLayer>
<GeoTIFFSource
sources={SOURCES}
attributions="Contains modified Copernicus Sentinel data 2024"
onViewReady={showScene}
/>
</WebGLTileLayer>
</Map>
);
}cog.shared.tsimport type { Coordinate } from 'ol/coordinate.js';
import type { SourceInfo } from 'ol/source/GeoTIFF.js';
const SCENE =
'https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/34/U/DA/2024/8/S2B_34UDA_20240814_0_L2A';
/** The Main Market Square in the scene's projection, UTM zone 34N (EPSG:32634). */
export const KRAKOW: Coordinate = [423901, 5545999];
export const SOURCES: SourceInfo[] = [{ url: `${SCENE}/TCI.tif` }];How the React version works
A true-colour Sentinel-2 scene over Kraków read as a Cloud Optimized GeoTIFF, shown in its own projection (UTM zone 34N) one resolution finer than the source suggests. The source reads the file in the browser, so nothing is drawn before its metadata arrive.
What both versions share
OpenLayers renders the map and handles the interactions; the cc-openlayers/core layer gives both adapters the same view binding (MapViewBinding) and the same conversion of coordinates from EPSG:4326 to the map's projection. OpenLayers draws the tiles with WebGL; the style expressions run on the GPU in both versions. Both versions import the centre over Kraków and the scene's sources from the example's .shared.ts file, so the logic exists once.
From Angular to React
| Angular | React |
|---|---|
<aol-layer-webgltile> with <aol-source-geotiff [sources]> inside | <WebGLTileLayer> with <GeoTIFFSource sources> inside, both from cc-openlayers/react/webgl |
(viewReady) with getView(..., withHigherResolutions(1)) | onViewReady with the same getView helpers, the result in useState |
<aol-view> with the options of the signal | <View> rendered with the options from state |
Who creates, updates and disposes
Map creates the ol/Map in useLayoutEffect and disposes of it on unmount; each layer, source and interaction component adds its object to the parent it gets from context and removes it in its effect's cleanup, as ngOnDestroy does in Angular.
Architecture and OpenLayers mechanics
aol-source-geotiff opens TCI.tif and emits its embedded projection (UTM zone 34N, EPSG:32634), extent and resolution pyramid via (viewReady). Helper showScene pipes those view options through withHigherResolutions(1)—adding one extra 5 m/px overzoom step beyond the file’s finest 10 m/px pixels.
@if (view(); as options) mounts aol-view once metadata is ready, starting at [resolution]="20" centred on krakow ([423901, 5545999] in UTM 34N metres).
How it works
aol-source-geotiffreads the three-band true-colourTCI.tifscene and emits native view options through(viewReady).withHigherResolutions(1)inshowSceneextends the view’s zoom ceiling one level finer than the file’s native 10 m pixels.@if (view(); as options)initialisesaol-viewin native UTM zone 34N at[resolution]="20"m/px once headers parse.krakowspecifies the Main Square centre in projected UTM 34N metres ([423901, 5545999]).
Pitfalls
- A view built directly from GeoTIFF metadata stops zooming at the file’s finest native pixel size (10 m/px here)—wrap view options with
withHigherResolutionswhenever users need closer street-level inspection. - When the view adopts the file’s native UTM projection,
centercoordinates must be given in UTM metres rather than WGS84 degrees.
Related examples
The same feature in the OpenLayers examples .
Background: state and lifecycle of maps in Angular with OpenLayers, which the components of cc-openlayers take care of.