Atlaslog
Atlaslog / Field Notes / deck.gl visualization
Field note · deck.gl visualization

Swapped lat/lng order sends every point to the Antarctic

Quick answer

The accessor returns [d.lat, d.lng] while deck.gl expects [lng, lat], so 39.9 becomes a longitude and 116.4 an out-of-range latitude. Mixing 2- and 3-element points in getPath also breaks the buffer length check.

Last verified 2026-11-03 · Multiple versions · Cite this page
Applies to: deck.gl
Symptom
Checklist
  1. Print data[0] with its raw field names and values.
  2. Call deck.pickObject at the intended location to see whether the data or the projection is wrong.
  3. Check that getPath and getPolygon arrays have a uniform arity.
  4. Verify each returned position against a known landmark.
Fix

Normalize fields to { lng, lat } before creating the layer and always return [d.lng, d.lat]; declare positionFormat: 'XY' for 2D paths and pad missing z with 0 for 'XYZ'.

Code
Error: deck.gl: attribute positions: length 2400 is not divisible by size 3
    at Attribute.updateBuffer (attribute.js:512)
console.log(data[0]);
// { lng: 116.391, lat: 39.907, z: null }
var p = [data[0].lat, data[0].lng];
console.log('错误写法得到的坐标', p);   // [39.907, 116.391]
Watch out
All 120 field notesChinese originalRunnable examples
English edition written for Atlaslog from the original Chinese field note. Code is unchanged and runs as-is.
Cite this page

Atlaslog (2026). Swapped lat/lng order sends every point to the Antarctic. https://www.jingweizhi.com/en/cookbook/deckgl-coord-dimension.html (accessed 2026-11-03).