English | 简体中文
Coordinate conversion utilities for the Chinese map coordinate systems, implementing the standard algorithms used by China's surveying authorities.
Chinese online maps are required by law to render coordinates with a non-linear offset applied — GCJ-02, colloquially "Mars coordinates". Raw GPS data (WGS-84) therefore does not line up with Amap, Baidu, or Tencent imagery, and mixing the two silently shifts points by several hundred metres. This toolkit makes the conversion explicit, verifiable, and reversible.
| System | Description | Used by |
|---|---|---|
| WGS-84 | Standard GPS coordinates | International systems, offline maps |
| GCJ-02 | Obfuscated "Mars" coordinates | Amap, Google China, Tencent |
| BD-09 | Baidu coordinates (GCJ-02 plus a second offset) | Baidu Maps |
| File | Purpose |
|---|---|
gcj2wgs_converter.py |
GCJ-02 → WGS-84, supports single points and batch conversion |
amap_wgs84_loader.py |
Loads Amap tiles in QGIS with real-time correction to WGS-84 |
test_coord_conversion.py |
Algorithm verification and error measurement |
# Convert GCJ-02 to WGS-84
python gcj2wgs_converter.py
# Run algorithm verification
python test_coord_conversion.pyfrom gcj2wgs_converter import gcj02_to_wgs84
# An Amap coordinate (GCJ-02)
gcj_lon, gcj_lat = 114.305202, 30.625309
# Convert to standard GPS coordinates (WGS-84)
wgs_lon, wgs_lat = gcj02_to_wgs84(gcj_lon, gcj_lat)
print(f"WGS-84: {wgs_lon:.6f}, {wgs_lat:.6f}")amap_wgs84_loader.py builds an Amap vector-tile layer inside QGIS that is reprojected from
GCJ-02 to WGS-84 at load time, so the basemap can be overlaid on standard GPS data without
manual offsetting. Run it from the QGIS Python console.
MIT © Retter Wang