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.
Symptom
- Shanghai People's Square GPS 121.473701, 31.230416; Baidu picker gives 121.484724, 31.234474; after lng-0.0065, lat-0.006 the result is 121.478224, 31.228474, still 481.8 m off.
- The leftover distance changes by city, so tuning the constant cannot remove it.
- Running gcj2wgs directly on the BD-09 value leaves a hundred-metre-level error.
Checklist
- 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.
- Run one more GCJ-02 to WGS84 pass on 121.478224, 31.228474 and see whether it returns 121.473701, 31.230416.
- Check whether the code calls gcj2wgs on a BD-09 value without the polar-shift inverse first.
- 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 mconst 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
- Treating the fixed 0.0065/0.006 subtraction as a complete BD-09 to WGS84 conversion.
- Hand-writing the polar-shift constants and dropping the 0.00002*sin(y*PI*3000/180) term, which leaves metre-level residue.
English edition written for Atlaslog from the original Chinese field note. Code is unchanged and runs as-is.
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).