Tile and image services · Angular, React and OpenLayers

A WMTS layer's time dimension

Browse daily NASA MODIS Terra satellite imagery over Poland in OpenLayers by binding a date slider to a REST WMTS Time dimension parameter.

Poland and its neighbours at zoom 6 in NASA's MODIS Terra true-colour image of 14 August 2025, cloudless over Poland and cloudy over the Alps, over OpenStreetMap.
A screenshot of the example. Imagery: NASA GIBS, MODIS Terra. Map data © OpenStreetMap contributors.

What this example shows

Across Poland and Central Europe at zoom 6, NASA’s daily true-colour MODIS Terra satellite composite from August 2025 renders over OpenStreetMap—opening on 1 August 2025, while the captured screenshot shows the nearly cloudless 14 August 2025 pass over Poland with Alpine cloud systems swirling to the south.

Dragging the date slider below the viewport steps day by day through August 2025, cross-fading each new satellite overpass smoothly over the previous day’s imagery.

When you need it

Earth-observation archives (NASA GIBS, Copernicus Marine/Atmosphere), meteorological ensembles and 4D ocean models publish multi-year daily rasters as a single WMTS layer parameterised by a Time or Elevation dimension.

Binding reactive UI state to WMTS dimensions lets users scrub through historical floods, wildfires, snow cover or crop growth without creating separate layers per date.

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.

wmts-dimensions.ts
import { ChangeDetectionStrategy, Component, computed, signal } from '@angular/core';
import {
  CoordinateComponent,
  DefaultControlComponent,
  DefaultInteractionComponent,
  LayerTileComponent,
  MapComponent,
  SourceOsmComponent,
  SourceTileWMTSComponent,
  ViewComponent,
} from 'cc-openlayers';
import { getTopLeft, getWidth } from 'ol/extent';
import { get as getProjection } from 'ol/proj';
import WMTSTileGrid from 'ol/tilegrid/WMTS';

const AUGUST_2025 = Date.UTC(2025, 7, 1);
const DAY = 24 * 60 * 60 * 1000;

/** GIBS's GoogleMapsCompatible_Level9 matrix set: the Spherical Mercator grid of 256-pixel tiles, levels 0 to 9. */
function level9Grid(): WMTSTileGrid {
  const extent = getProjection('EPSG:3857')?.getExtent() ?? [];
  const levels = [...Array(10).keys()];
  return new WMTSTileGrid({
    origin: getTopLeft(extent),
    resolutions: levels.map((level) => getWidth(extent) / 256 / 2 ** level),
    matrixIds: levels.map(String),
  });
}

/**
 * A WMTS dimension changed continuously: the slider picks a day of August 2025, and the same source asks NASA GIBS
 * for that day's true-colour image from MODIS Terra, whose tiles fade in over the last day's.
 */
@Component({
  selector: 'app-wmts-dimensions',
  imports: [
    CoordinateComponent,
    DefaultControlComponent,
    DefaultInteractionComponent,
    LayerTileComponent,
    MapComponent,
    SourceOsmComponent,
    SourceTileWMTSComponent,
    ViewComponent,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <aol-map height="480px">
      <aol-interaction-default />
      <aol-control-defaults />
      <aol-view [zoom]="6">
        <aol-coordinate [x]="19.9373" [y]="50.0617" srid="EPSG:4326" />
      </aol-view>
      <aol-layer-tile><aol-source-osm /></aol-layer-tile>
      <aol-layer-tile [opacity]="0.8">
        <aol-source-tilewmts
          url="https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/MODIS_Terra_CorrectedReflectance_TrueColor/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpeg"
          layer="MODIS_Terra_CorrectedReflectance_TrueColor"
          matrixSet="GoogleMapsCompatible_Level9"
          format="image/jpeg"
          requestEncoding="REST"
          [style]="'default'"
          [tileGrid]="tileGrid"
          [dimensions]="{ Time: date() }"
          attributions="Imagery: NASA GIBS, MODIS Terra"
        />
      </aol-layer-tile>
    </aol-map>
    <div class="example-controls">
      <label>
        Day
        <input id="slider" type="range" min="0" max="30" [value]="day()" (input)="slide($event)" />
      </label>
      <span id="theinfo">{{ date() }}</span>
    </div>
  `,
})
export class WmtsDimensions {
  readonly day = signal(0);
  protected readonly date = computed(() => new Date(AUGUST_2025 + this.day() * DAY).toISOString().slice(0, 10));
  protected readonly tileGrid = level9Grid();

  protected slide(event: Event): void {
    this.day.set(Number((event.target as HTMLInputElement).value));
  }
}

Architecture and OpenLayers mechanics

Configured with requestEncoding="REST", the WMTS source populates URL template tokens directly: {TileMatrix}, {TileRow} and {TileCol} from tile coordinates, {TileMatrixSet} from matrixSet, and {Time} from [dimensions]. Whenever the slider updates Time, OpenLayers invalidates stale requests and fetches tiles for the newly chosen ISO date while retaining previous tiles underneath until replacements arrive.

level9Grid defines NASA GIBS’s GoogleMapsCompatible_Level9 Web Mercator pyramid (256-pixel tiles across levels 0–9), automatically upscaling level-9 tiles if the user zooms closer.

How it works

  • requestEncoding="REST" fills {TileMatrixSet}, {TileMatrix}, {TileRow}, {TileCol} and {Time} directly in NASA GIBS’s RESTful URL template.
  • Binding Time inside [dimensions] triggers fresh daily tile requests whenever the date slider moves.
  • level9Grid configures the 256-pixel GoogleMapsCompatible_Level9 Web Mercator grid (levels 0–9), overzooming cleanly past zoom 9.
  • Outgoing daily tiles stay visible until incoming tiles decode and fade in, avoiding blank flashes while scrubbing dates.

Pitfalls

  • While new tiles stream in over slow connections, adjacent squares can momentarily show two different dates side by side—watch layer load events if analysts must know when the entire frame reflects one single day.
  • True-colour optical sensors like MODIS capture real cloud cover alongside land surfaces, so cloudy summer days naturally obscure the ground.

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.