Atlaslog
Atlaslog / deck.gl / Tutorial / Data sources and binary attributes
deck.gl · Tutorial

Data sources and binary attributes

Quick answer

This tutorial compares three ways to feed deck.gl layers: plain object arrays, GeoJSON FeatureCollections and binary attributes with length plus attributes. It shows building Float32Array positions, radii and Uint8Array colors, loading CSV through loaders.gl, and applying DataFilterExtension so threshold changes avoid re-uploading buffers. Readers can choose a representation by data size and update frequency.

Last verified 2026-11-03 · deck.gl 9.0 · Cite this page
Key points
Example
var N = stations.length;
var positions = new Float32Array(N * 2);
var radii = new Float32Array(N);
var colors = new Uint8Array(N * 4);

for (var i = 0; i < N; i++) {
  positions[i * 2] = stations[i].lng;
  positions[i * 2 + 1] = stations[i].lat;
  radii[i] = stations[i].flow > 800 ? 9 : 5;
  colors[i * 4] = 40;
  colors[i * 4 + 1] = 140;
  colors[i * 4 + 2] = 255;
  colors[i * 4 + 3] = 200;
}

var binaryData = {
  length: N,
  attributes: {
    getPosition: { value: positions, size: 2 },
    getRadius: { value: radii, size: 1 },
    getFillColor: { value: colors, size: 4 }
  }
};

new deck.ScatterplotLayer({
  id: 'stations-binary',
  data: binaryData,
  radiusUnits: 'pixels',
  pickable: true
});
import { load } from '@loaders.gl/core';
import { CSVLoader } from '@loaders.gl/csv';

const rows = await load('/data/stations.csv', CSVLoader);

new deck.ScatterplotLayer({
  id: 'stations-csv',
  data: rows,
  getPosition: function (d) {
    return [Number(d.lng), Number(d.lat)];
  },
  getRadius: 6,
  radiusUnits: 'pixels'
});
new deck.GeoJsonLayer({
  id: 'districts',
  data: '/data/districts.geojson',
  filled: true,
  getFillColor: [31, 95, 208, 60],
  getLineColor: [31, 95, 208, 220]
});
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). Data sources and binary attributes. https://www.jingweizhi.com/en/deckgl/tutorials/data-formats.html (accessed 2026-11-03).