Raster, GeoTIFF and WebGL · Angular, React and OpenLayers

Retina image tiles on a logical XYZ grid

Render 512-pixel @2x Retina WebP satellite tiles on a standard 256-pixel logical XYZ grid over Kraków using OpenLayers ImageTile and WebGL.

Kraków satellite imagery around Rynek Główny from the local high-density XYZ tile set.
A screenshot of the example. Contains modified Copernicus Sentinel data 2024.

What this example shows

Centred on Rynek Główny in Kraków across zooms 11 through 13, crisp 512 × 512 pixel @2x WebP Sentinel-2 satellite tiles render on a standard 256-pixel logical XYZ map grid through OpenLayers’ ImageTile and WebGL adapters while preserving Copernicus attribution.

When you need it

High-DPI tile endpoints (@2x WebP/PNG pyramids) pack four times as many image pixels into each standard {z}/{x}/{y} geographic square so fine urban textures stay sharp on Retina phones and 4K monitors.

Keeping the logical XYZ grid at 256 CSS pixels ensures tile coordinates and geographic bounds stay 100% aligned with standard vector and raster overlays.

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.

xyz-retina.shared.ts
import type { Extent } from 'ol/extent';
import type { DefaultsOptions } from 'ol/control/defaults';
import coverage from '../../../assets/krakow/retina-tiles/coverage.json';

export const XYZ_RETINA_URL = 'assets/krakow/retina-tiles/{z}/{x}/{y}@2x.webp';
export const RETINA_TILE_SIZE = coverage.tileSize;
export const RETINA_ATTRIBUTION_OPTIONS: DefaultsOptions['attributionOptions'] = { collapsible: false };
export const RETINA_MIN_ZOOM = coverage.zoomLevels[0];
export const RETINA_MAX_ZOOM = coverage.zoomLevels[coverage.zoomLevels.length - 1];
export const RETINA_EXTENT = coverage.extent as Extent;
export const RETINA_ATTRIBUTIONS = [
  'Contains modified Copernicus Sentinel data 2024. ' +
    '<a href="https://cds.climate.copernicus.eu/licences/ec-sentinel" target="_blank" rel="noreferrer">' +
    'Copernicus Sentinel notice</a>; ' +
    '<a href="https://dataspace.copernicus.eu/terms-and-conditions" target="_blank" rel="noreferrer">' +
    'Copernicus Data Space terms</a>',
];
xyz-retina.ts
import { ChangeDetectionStrategy, Component } from '@angular/core';
import {
  CoordinateComponent,
  DefaultControlComponent,
  DefaultInteractionComponent,
  MapComponent,
  SourceImageTileComponent,
  ViewComponent,
} from 'cc-openlayers';
import { LayerWebGLTileComponent } from 'cc-openlayers/webgl';
import {
  RETINA_ATTRIBUTIONS,
  RETINA_ATTRIBUTION_OPTIONS,
  RETINA_EXTENT,
  RETINA_MAX_ZOOM,
  RETINA_MIN_ZOOM,
  RETINA_TILE_SIZE,
  XYZ_RETINA_URL,
} from './xyz-retina.shared';

/** Displays the local Kraków crop from 512 px WebP tiles on OpenLayers' 256 px tile grid. */
@Component({
  selector: 'app-xyz-retina',
  imports: [
    CoordinateComponent,
    DefaultControlComponent,
    DefaultInteractionComponent,
    LayerWebGLTileComponent,
    MapComponent,
    SourceImageTileComponent,
    ViewComponent,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <aol-map height="480px" ariaLabel="Kraków Sentinel XYZ density example">
      <aol-interaction-default />
      <aol-control-defaults [attributionOptions]="attributionOptions" />
      <aol-view [extent]="extent" [constrainOnlyCenter]="true" [minZoom]="minZoom" [maxZoom]="maxZoom" [zoom]="12">
        <aol-coordinate [x]="19.9368" [y]="50.0614" srid="EPSG:4326" />
      </aol-view>
      <aol-layer-webgltile [extent]="extent">
        <aol-source-imagetile
          [url]="url"
          [tileSize]="tileSize"
          [minZoom]="minZoom"
          [maxZoom]="maxZoom"
          projection="EPSG:3857"
          [wrapX]="false"
          [attributions]="attributions"
        />
      </aol-layer-webgltile>
    </aol-map>
  `,
})
export class XyzRetina {
  protected readonly attributions = RETINA_ATTRIBUTIONS;
  protected readonly attributionOptions = RETINA_ATTRIBUTION_OPTIONS;
  protected readonly extent = RETINA_EXTENT;
  protected readonly minZoom = RETINA_MIN_ZOOM;
  protected readonly maxZoom = RETINA_MAX_ZOOM;
  protected readonly tileSize = RETINA_TILE_SIZE;
  protected readonly url = XYZ_RETINA_URL;
}

Architecture and OpenLayers mechanics

Local same-origin XYZ URLs point directly at 512 × 512 @2x WebP crops sampled from a 10 m Copernicus Sentinel-2 scene over Kraków, while the source’s logical tile grid remains the standard 256-pixel Web Mercator pyramid—matching upstream OpenLayers’ ImageTile Retina pattern without altering geographic cell footprints.

How it works

  • Same-origin @2x WebP tile files supply 512 × 512 image pixels per standard 256-pixel logical XYZ cell.
  • Following the upstream ImageTile pattern, the source keeps the default 256-pixel logical grid without switching URLs by device DPR.
  • A bounded local Sentinel-2 fixture over Kraków (zooms 11–13) provides self-contained high-density imagery with visible Copernicus attribution.
  • Tiles stay crisp to about zoom 12 (~12 m/px); at zoom 13 the 2x tiles interpolate the 10 m source, so no sub-sensor detail appears.

Pitfalls

  • Do not change the logical tileSize to 512 when a server returns @2x tiles for standard 256-pixel XYZ coordinates—doubling logical grid size shifts zoom levels and misplaces every tile.
  • Upscaling a blurry 256 px tile to 512 px wastes bandwidth; true @2x tiles must be rendered or sampled from higher-resolution source data.
  • Keep view zoom and extent aligned with bounded local tile fixtures so out-of-coverage cells are not requested.

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.