Atlaslog
Atlaslog / Field Notes / Coordinates & projections
Field note · Coordinates & projections

Fixed 0.0065 subtraction from BD-09 still leaves 481 m

Quick answer

Subtracting 0.0065 and 0.006 from a Baidu coordinate only brings it back to GCJ-02, so 481.8 m to WGS84 remains. The residual is not constant: it becomes 606.6 m in Shenzhen and 621.7 m in Guangzhou.

Last verified 2026-11-03 · Multiple versions · Cite this page
Applies to: Baidu Map JS API 3.0 · Leaflet 1.9.x · gcoord 1.0.x
Symptom
Checklist
  1. Subtract 0.0065/0.006 from the picker coordinate and compare with a known GCJ-02 value; a match proves the code stopped at GCJ-02.
  2. Run one more GCJ-02 to WGS84 pass on 121.478224, 31.228474 and see whether it returns 121.473701, 31.230416.
  3. Check whether the code calls gcj2wgs on a BD-09 value without the polar-shift inverse first.
  4. Validate with a second city: Beijing Tiananmen BD-09 116.410172, 39.916634 must return 116.403672, 39.910634 within 0.5 m.
Fix

Run the full two-stage chain BD-09 to GCJ-02 (polar shift inverse) then GCJ-02 to WGS84, or simply call gcoord.transform(data, 'BD09', 'WGS84'), which has the BD09 branch built in.

Code
const gcj = [121.484724 - 0.0065, 31.234474 - 0.006];
// => [121.478224, 31.228474]  距 GPS 原始点 481.8 m
const X_PI = Math.PI * 3000 / 180;

// BD-09 -> GCJ-02
function bd09ToGcj(lng, lat) {
  const x = lng - 0.0065, y = lat - 0.006;
  const z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * X_PI);
  const theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * X_PI);
  return [z * Math.cos(theta), z * Math.sin(theta)];
}
function gcjToWgs(lng, lat) {
  let wgs = [lng, lat];
  for (let i = 0; i < 3; i++) {
    const g = wgsToGcj(wgs[0], wgs[1]);
    wgs[0] -= g[0] - lng;
    wgs[1] -= g[1] - lat;
  }
  return wgs;
}

const wgs = gcjToWgs(...bd09ToGcj(121.484724, 31.234474));
// => [121.473701, 31.230416] 与 GPS 点相差 0.02 m
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). Fixed 0.0065 subtraction from BD-09 still leaves 481 m. https://www.jingweizhi.com/en/cookbook/bd09-fixed-minus.html (accessed 2026-11-03).