Restrictions on geographic data in China


Due to national law, the use of geographic information in the People's Republic of China is restricted to entities that obtain a special authorization from the administrative department for surveying and mapping under the State Council. Consequences of the restriction include fines for unauthorized surveys, lack of geotagging information on many cameras when the GPS chip detects a location within China, incorrect alignment of street maps with satellite maps in various applications, and seeming unlawfulness of crowdsourced mapping efforts such as OpenStreetMap.

Legislation

According to articles 7, 26, 40 and 42 of the Surveying and Mapping Law of the People's Republic of China, private surveying and mapping activities have been illegal in mainland China since 2002. The law prohibits
Fines range from 10,000 to 500,000 CNY. Foreign individuals or organizations that wish to conduct surveying must form a Chinese-foreign joint venture.
Between 2006 and 2011, the authorities pursued nearly 40 illegal cases of mapping and surveying. The media has reported on other cases of unlawful surveys:
As a consequence, major digital camera manufacturers including Panasonic, Leica, FujiFilm, Nikon and Samsung restrict location information within China.
OpenStreetMap, the crowdsourced project to assemble a map of the world, advises that "private surveying and mapping activities are illegal in China".

Coordinate systems

Chinese regulations mandate that approved map service providers in China use a specific coordinate system, called GCJ-02. Baidu Maps uses yet another coordinate system - BD-09, which seems to be based on GCJ-02.

GCJ-02

GCJ-02 is a geodetic datum formulated by the Chinese State Bureau of Surveying and Mapping, and based on WGS-84. It uses an obfuscation algorithm which adds apparently random offsets to both the latitude and longitude, with the alleged goal of improving national security. There is a license fee associated with using this mandatory algorithm in China.
A marker with GCJ-02 coordinates will be displayed at the correct location on a GCJ-02 map. However, the offsets can result in a 100 - 700 meter error from the actual location if a WGS-84 marker is placed on a GCJ-02 map, or vice versa. The Google.com street map is offset by 50–500 meters from its satellite imagery, while the Google.cn map is not. Yahoo! Maps also displays the street map without major errors when compared to the satellite imagery. MapQuest overlays OpenStreetMap data perfectly as well.
Despite the secrecy surrounding the GCJ-02 obfuscation, several open-source projects exist that provide conversions between GCJ-02 and WGS-84, for languages including C#, C, Go, Java, JavaScript, PHP, Python, R, and Ruby. They appear to be based on leaked code for the WGS to GCJ part. Other solutions to the conversion involve interpolating coordinates based on regression from a data set of Google China and satellite imagery coordinates. An attempt by Wu Yongzheng using fast Fourier transform analysis gave a result much like the leaked code.
From the leaked code, GCJ-02 uses parameters from the SK-42 reference system. The parameters were used to calculate lengths of one degree of latitude and longitude, so that offsets in meters previously calculated can be converted to degrees for the WGS-84 input coordinates.

BD-09

BD-09 is a geographic coordinate system used by Baidu Maps, adding further obfuscation to GCJ-02 "to better protect users' privacy". Baidu provides an API call to convert from Google or GPS, GCJ-02, BD-09, or coordinates into Baidu or GCJ-02 coordinates. As required by local law, there is no API to convert into WGS-84, but open source implementations in R and various other languages exist.

Reverse transformation

GCJ-02 appears to use multiple high-frequency noises of the form, effectively generating a transcendental equation and thus eliminating analytical solutions. However, the open-source "reverse" transformations make use of the properties of GCJ-02 that the transformed coordinates are not too far from WGS-84 and are mostly monotonic related to corresponding WGS-84 coordinates:

from typing import Callable
  1. Represent coordinates with complex numbers for simplicity
coords = complex
  1. Coords-to-coords function
C2C = Callablecoords], coords]
def rev_transform_rough -> coords:
"""Roughly reverse the ``worsen`` transformation.
Since ``bad = worsen`` is close to ``good``,
``worsen - bad`` can be used to approximate ``bad - good``.
First seen in eviltransform.
"""
return bad -
def rev_transform -> coords:
"""More precisely reverse the ``worsen`` transformation.
Similar to ``rev_transform_rough``,
``worsen - worsen`` can be used to approximate ``a - b``.
First seen in geoChina/R/cst.R.
Iteration-only version has been known
since fengzee-me/ChinaMapShift.
"""
eps = 1e-6
wgs = rev_transform_rough
improvement = 99 + 99j # dummy value
while abs > eps:
improvement = worsen - bad
wgs = wgs - improvement
return wgs

The rough method is reported to give some 1~2 meter accuracy for wgs2gcj, while the exact method is able to get "centimeter accuracy" in two calls to the forward function. Since the two properties ensure some basic functionality of the coordinate system, it is unlikely that the methods will change with new coordinate systems. The BD-to-GCJ code works in a manner much like the rough method, except that it removes the explicitly-applied constant shift of ~20 seconds of arc on both coordinates first and works in polar coordinates like the forward function does.
The establishment of working conversion methods both ways largely renders obsolete datasets for deviations mentioned below.

GPS shift problem

The China GPS shift problem is a class of issues stemming from the difference between the GCJ-02 and WGS-84 datums. Global Positioning System coordinates are expressed using the WGS-84 standard and when plotted on street maps of China that follow the GCJ-02 coordinates, they appear off by a large and variable amount. Authorized providers of location-based services and digital maps must purchase a "shift correction" algorithm that enables plotting GPS locations correctly on the map. Satellite imagery and user-contributed street map data sets, such as those from OpenStreetMap also display correctly because they have been collected using GPS devices.
Some map providers, such as Here, choose to also offset their satellite imagery layer to match the GCJ-02 street map.
Google has worked with Chinese location-based service provider AutoNavi since 2006 to source its maps in China.
google.cn/maps uses the GCJ-02 system for both its street maps and satellite imagery. However, the WGS-84 positions reported by a browser are depicted at the wrong positions. On the contrary, google.com/maps also uses GCJ-02 data for the street map, but does not shift the satellite imagery layer, which continues to use WGS-84 coordinates, with the benefit that WGS-84 positions can still be overlaid correctly on the satellite image. Google Earth also uses WGS-84 to display the satellite imagery.
Overlaying GPS tracks on Google.com Maps and any street maps sourced from Google.com via its API, will lead to a similar display offset problem, because GPS tracks use WGS-84, and Google.com maps use GCJ-02. The issue has been reported numerous times on the Google Product Forums since 2009, with 3rd party applications emerging to fix it. Data sets with offsets for large lists of Chinese cities existed for sale. The problem was observed as early as 2008, and the causes were unclear, with speculation that imported GPS chips were tampered with code that caused incorrect reporting of coordinates.

Hong Kong and Macau

Under One Country Two Systems, legislation in mainland China does not apply in Hong Kong and Macau SARs and there are no similar restrictions in the SARs. Therefore, the GPS shift problem does not apply. However, at the border between the SARs and mainland China, the data shown by online maps are broken where the shifted data and correct data overlap. This poses problems to users travelling across the border, especially visitors not aware of the issue.