Atlaslog
Atlaslog / deck.gl / Tutorial / Aggregation layers: hexagons and heatmaps
deck.gl · Tutorial

Aggregation layers: hexagons and heatmaps

Quick answer

This tutorial explains that HexagonLayer and HeatmapLayer bin raw points on the GPU before coloring, and why radius and cellSize are measured in meters while radiusPixels is in screen pixels. It configures getColorWeight, colorAggregation, coverage, extruded, elevationScale and colorDomain, then combines a HeatmapLayer at low zoom with a HexagonLayer when zoomed in. Readers can pick the right density encoding and tune it.

Last verified 2026-11-03 · deck.gl 9.0 · Cite this page
Key points
Example
var hexagon = new deck.HexagonLayer({
  id: 'density-hex',
  data: stations,
  getPosition: function (d) { return [d.lng, d.lat]; },
  getColorWeight: function (d) { return d.flow; },
  colorAggregation: 'SUM',
  radius: 900,
  coverage: 0.92,
  extruded: true,
  elevationScale: 12,
  elevationRange: [0, 3000],
  colorRange: [
    [255, 245, 200],
    [255, 210, 120],
    [255, 160, 60],
    [240, 100, 40],
    [190, 40, 60]
  ],
  pickable: true,
  autoHighlight: true
});
var heat = new deck.HeatmapLayer({
  id: 'density-heat',
  data: stations,
  getPosition: function (d) { return [d.lng, d.lat]; },
  getWeight: function (d) { return d.flow; },
  radiusPixels: 42,
  intensity: 1.4,
  threshold: 0.06,
  colorRange: [
    [0, 0, 255, 0],
    [0, 128, 255, 120],
    [0, 255, 200, 180],
    [255, 220, 0, 220],
    [255, 80, 0, 255]
  ],
  aggregation: 'SUM'
});
Notes
Runnable examplesChinese originalAll Tutorials
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Aggregation layers: hexagons and heatmaps. https://www.jingweizhi.com/en/deckgl/tutorials/aggregation.html (accessed 2026-11-03).