If you look at China on Google Maps, you might notice something weird.
Everywhere you go in China, the vector road elements will be slightly misplaced relative to the satellite imagery. You can see this with amusing clarity at the China-Vietnam border.
Or the China-Pakistan border:
The distortion seems non-trivial, in different directions at different places. The reason for this is a government-mandated distortion algorithm called “GCJ-02” and known colloquially as the Mars coordinate system. The official name translates to “nonlinear confidentiality processing technology for topographic maps.”
On account of the “Surveying and Mapping Law of the People’s Republic of China,” private surveys have been illegal in the country since 2002. Article 34 of it instructs that authorities promote a “public version” of surveying results that are passed through “confidentiality technical processing.” In other words, surveying data is a state secret unless it is processed. This went into effect after GB 20263-2006, “Basic Requirements of Security Processing Technology for Navigable Electronic Maps,” which was effective October 1, 2006. The standard does not apply just to Chinese products, but to any mapping service operating in China. It is even illegal for foreigners to use an ordinary GPS device in China.
This is why in 2006, Google Maps began sourcing Chinese map data through AutoNavi (now Amap). Their satellite imagery is sourced separately and uses the regular WGS-84 datum, so it does not have the same distortion applied as the vector data.
South Korea and Russia have had similar restrictions on geographic data in the past, but nothing similar to the Mars coordinate system. I guess getting invaded by Japan has some correlation with being protective of geographic data.
If you look at Chinese maps instead, like Baidu Maps, the distortion issue seems to go away.
But this is illusory. Usually, Baidu doesn’t let you view high-resolution satellite imagery for countries besides China. However, you can sometimes get a peak at borders, where those other countries seem to have distorted map data. This is China and Kazakhstan.
Back when Google Maps had a Chinese variant (it has been defunct since 2020), you instead saw a discontinuity at borders between China and other countries.
Chinese Google Maps would just distort satellite data along with the vector data by the GCJ-02 algorithm for places in China. Although the coordinates of everything were technically false, this did not matter for practical use except in the edge cases (national borders). For today’s Baidu, it appears that they distort satellite imagery all around the world, but do not do this for vector data outside China.
In January 2010, someone suggested using regression to reverse engineer the GCJ-02 algorithm. This proved unnecessary. Later that year, the source code of a GIS application developed for electrical power infrastructure, called “EMQ,” was uploaded onto Google Code. It happened to include a function for converting from WGS-84 to GCJ-02. An entertaining Chinese article explains how it was reverse-engineered, but I will explain it here. The relevant part of the code is this:
The sequence appears to be:
Subtract the coordinates of the center of China (105, 35)
Use two functions to find a latitude and longitude distortion in meters based on the coordinate
Add a second distortion to this based on time
Convert the meters offset to longitude and latitude
It appears that step 3 was not part of the GCJ algorithm and was tacked on by the developers of this application. The distortion applied in step 2 was simply a polynomial plus a sum of sine waves. Specifically,
where x and y are the adjusted longitudes and latitudes in degrees, and d is in meters.
To convert meters to degrees, you need to decide which ellipsoid you are using to represent the Earth. While the input datum is WGS-84, Mars applies an additional layer of distortion by using an obscure ellipsoid for the output coordinates. This is the Krasovsky 1940 ellipsoid, used by the Soviet Union’s SK-42 datum.
Both these transformations are nonlinear.
Notice the vertical bands: if you refer to the formula, strangely the higher frequency components only depend on x, not y. The 6πx term has a period of ⅓ degrees, which is around 30 km in China, so the distortion is not visible in normal use of the maps.
The distortion is never west-ward within China.
As expected, there are some areas in Qinghai province where the distortion is minimal, but it is still around 17.5 m.
Because the maps have to be suitable for ordinary use, the magnitude and direction of distortion cannot vary too much within a single place. Thus the Mars coordinate transformation is locally linear.
The effect of this is that it is easy to invert the function. If (x1, y1) ≈ (x2, y2) then m(x1, y1) - (x1, y1) ≈ m(x2, y2) - (x2, y2). Since m(x, y) ≈ (x, y), use that as your first guess.
Then (xn+1, yn+1) = (xn, yn) + m(x, y) - m(xn, yn).
After 2 iterations the error is already below 1m.
There is a well-maintained library that does this on GitHub called “eviltransform.”
Baidu applies a layer of encryption on top, called BD-09. It converts the latitude and longitude, read as Cartesian coordinates, to Polar coordinates. Then it applies a distortion to the magnitude and argument of these coordinates, then converts back to Cartesian coordinates, then adds a constant distortion on top.
This was reverse engineered from the Baidu Maps app in 2013. BD-09 can be reversed using similar means to GCJ-02.
But where can I see the real map of China? OpenStreetMap is fully user-contributed and thus does not have any distortion baked into its data. Unfortunately, it was banned in mainland China on October 28, 2022, as it was already illegal. It is also illegal to contribute to OSM. The data quality in China is nonetheless pretty good.
The US had tried something similar from 1990 to 2000, called Selective Availability (SA). They would add some pseudo-random noise to the signals broadcasted by GPS satellites, distorting their position and the atomic clock time. The errors were up to 100 meters. Only those with the cryptographic key could access GPS to its full precision.
However, there were a couple of flaws that rendered SA relatively ineffective. The first is that the receiver may average their GPS positions over time to get a more precise estimate. The other rests on a similar issue to China’s measures: local linearity. The offset caused by SA in one place will be similar to the offset in a nearby location. A ground station with a precisely known location can thus broadcast this offset to receivers who can adjust accordingly. This is known as Differential GPS (DGPS), and a similar system is used for modern surveying.
At the time, this was not something illicit, but a system that multiple government agencies advocated for, and with a wide coverage of ground stations. In fact, advanced forms of DGPS were even more precise than regular GPS without SA, with 10 cm accuracy. Because it was counterproductive, Bill Clinton signed an executive order that ended Selective Availability in 2000.
Given how easy it is to reverse, it seems doubtful that Mars serves any national security goals other than annoying people. Indeed, because local linearity is a necessity for usable maps, I doubt any similar system can avoid easy reversal. I would be interested in being proven wrong on that. In the meantime, China should get rid of this useless system.












