Yesterday we talked about how the Street Maps of China are offset from the satellite imagery because of their laws requiring the use of the GCJ-02 datum. The GCJ-02 datum moves the map by different amounts in different places. You can typically work out correct coordinates by a simple addition or subtraction to latitude and longitude for a given area, but the amount to be added or subtracted varies across the country. So for a given city in China a particular set of offsets unique to that city would suffice for most purposes, but for countrywide mapping it is a lot more complicated.
We thought it would be interesting to get an overall view of how much the map is offset and in which direction. We found some Java code here to convert from WGS-84 to GCJ-02 and converted it to JavaScript for use in this post. We later found another version on Github that includes JavaScript code.
The first thing we did was to create this KML file that shows the relative magnitudes and directions of the offsets.
The smallest offsets are near Haixi (just left of centre), and the largest offsets are in the northeast of China.
Note that the magnitudes displayed above are relative. Actual magnitudes vary from a few metres to a few hundred metres and would not be visible at that scale.
Our next step was to create a converter to use with Google Earth. If you have a GPS track that uses the standard WGS-84 coordinates and you want it to match the Google Earth street map, then it might be useful. Just save it as a KML and use the converter below. It should work on most KML features, but ignores the camera position, but that shouldn’t matter for most applications. We make no guarantees regarding accuracy. The conversion is done in JavaScript and the file is never uploaded to our servers.
WGS-84 to GCJ-02 KML converter:
We have also discovered that Baidu Maps uses yet another coordinate system called BD-09 that is based on GCJ-02 but adds further encryption. Baidu provides a converter to BD-09 as part of their API.