Atlaslog
Atlaslog / deck.gl / API / ContourLayer
deck.gl · API reference

ContourLayer

Quick answer

The ContourLayer aggregates data into iso-lines or iso-bands for a given threshold and cell size. Isoline represents collection of line segments that se.

Last verified 2026-11-03 · deck.gl 9.0 · Cite this page
Runnable examplesChinese noteAll API topics

The ContourLayer aggregates data into iso-lines or iso-bands for a given threshold and cell size. Isoline represents collection of line segments that separate the area above and below a given threshold. Isoband represents a collection of polygons (filled) that fill the area containing values in a given threshold range. To generate an Isoline single threshold value is needed, to generate an Isoband an array with two values needed. Data is first aggregated using given cell size and resulting scalar field is used to run Marching Squares algorithm that generates a set of vertices to form Isolines or Isobands. In below documentation Isoline and Isoband is referred as contour.

import {Deck} from '@deck.gl/core';
import {ContourLayer} from '@deck.gl/aggregation-layers';

const layer = new ContourLayer({
id: 'ContourLayer',
data: 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-bike-parking.json',

cellSize: 200,
contours: [
{threshold: 1, color: [255, 0, 0], strokeWidth: 2, zIndex: 1},
{threshold: [3, 10], color: [55, 0, 55], zIndex: 0},
{threshold: 5, color: [0, 255, 0], strokeWidth: 6, zIndex: 2},
{threshold: 15, color: [0, 0, 255], strokeWidth: 4, zIndex: 3}
],
getPosition: d => d.COORDINATES,
getWeight: d => d.SPACES,
pickable: true
});

new Deck({
initialViewState: {
longitude: -122.4,
latitude: 37.74,
zoom: 11
},
controller: true,
getTooltip: ({object}) => object && `threshold: ${object.contour.threshold}`,
layers: [layer]
});

Installation​

To install the dependencies from NPM:

npm install deck.gl
# or
npm install @deck.gl/core @deck.gl/layers @deck.gl/aggregation-layers
import {ContourLayer} from '@deck.gl/aggregation-layers';
import type {ContourLayerProps, ContourLayerPickingInfo} from '@deck.gl/aggregation-layers';

new ContourLayer<DataT>(...props: ContourLayerProps<DataT>[]);

To use pre-bundled scripts:

<script src="https://unpkg.com/deck.gl@^9.0.0/dist.min.js"></script>
<!-- or -->
<script src="https://unpkg.com/@deck.gl/core@^9.0.0/dist.min.js"></script>
<script src="https://unpkg.com/@deck.gl/layers@^9.0.0/dist.min.js"></script>
<script src="https://unpkg.com/@deck.gl/aggregation-layers@^9.0.0/dist.min.js"></script>
new deck.ContourLayer({});

Properties​

Inherits from all Base Layer properties.

Aggregation Options​

cellSize (number, optional) ​

Size of each cell in meters

gpuAggregation (boolean, optional)​

When set to true and the browser supports it, aggregation is performed on GPU.

In the right context, enabling GPU aggregation can significantly speed up your application. However, depending on the nature of input data and required application features, there are pros and cons in leveraging this functionality. See CPU vs GPU aggregation for an in-depth discussion.

aggregation (string, optional)​

Defines the operation used to aggregate all data object weights to calculate a cell's value. Valid values are:

getWeight and aggregation together determine the elevation value of each cell.

Render Options​

contours (object[], optional)​

Array of objects with following keys

NOTE: Like any other layer prop, a shallow comparison is performed on contours prop to determine if it is changed. This prop should be set to an array object, that changes only when contours need to be changed.

zOffset (number, optional)​

A very small z offset that is added for each vertex of a contour (Isoline or Isoband). This is needed to control the layout of contours, especially when rendering overlapping contours. Imagine a case where an Isoline is specified which is overlapped with an Isoband. To make sure the Isoline is visible we need to render this above the Isoband.

Data Accessors​

getPosition (Accessor<Position>, optional)​

Method called to retrieve the position of each object.

getWeight (Accessor<number>, optional)​

The weight of each object.

Picking​

The PickingInfo.object field returned by hover/click events of this layer represents a path (isoline) or a polygon (isoband). The object contains the following fields:

Sub Layers​

The ContourLayer renders the following sublayers:

Source​

modules/aggregation-layers/src/contour-layer

TutorialsAPI index
English reference text adapted from the official deck.gl documentation, © vis.gl contributors, licensed under MIT.
Original page: https://deck.gl/docs/api-reference/aggregation-layers/contour-layer · Chinese note: /deckgl/api/contour-layer.html
Cite this page

Atlaslog (2026). ContourLayer. https://www.jingweizhi.com/en/deckgl/api/contour-layer.html (accessed 2026-11-03).