Use QGIS plug-in to convert Mars coordinates, Baidu coordinates and WGS84 coordinates

Recently, due to work needs, a batch of POI point data has been downloaded from AutoNavi and Baidu. As Gaode maps use the GCJ02 coordinate system of the National Bureau of Surveying, Mapping and Geographic Information (commonly known as the Mars coordinate system), Baidu uses its own BD09 coordinate system, and most international source maps use the WGS84 coordinate system, which results in data from multiple sources cannot be superimposed on the same On the base map, therefore, it is necessary to convert between coordinates.

Common coordinate systems for Internet maps

  • GCJ02 coordinate system

For the sake of confidentiality, the National Bureau of Surveying, Mapping and Geographic Information uses special algorithms to non-linearly encrypt the coordinates. The encrypted coordinates are the GCJ02 coordinate system, also known as the Mars coordinate system.

Most of the officially released electronic maps in China use the GCJ02 coordinate system, such as AutoNavi Maps, Tencent Maps, and Google Maps in China.

  • Baidu coordinate system

The Baidu coordinate system is a secondary encryption based on the GCJ02 coordinate system, and is currently mainly used by Baidu Maps.

  • WGS84 coordinate system

Generally, the coordinates obtained from the international standard GPS equipment are WGS84 coordinates, which is a coordinate system widely used by international map providers, such as OpenStreetMap, ARCGIS online map, Bing map, etc.

Coordinate conversion

Electronic map data of different coordinate systems will have position deviations when they are superimposed, resulting in unusable, coordinate conversion is required to eliminate the deviation. There are many ways to realize the conversion between coordinates, such as directly writing algorithm implementation; using Web API implementation or using existing plug-ins.

In QGIS, the GeoHey Toolbox plug-in provided by the GeoHey team can realize the conversion between Mars coordinates, Baidu coordinates and WGS84 coordinates, which provides great convenience for users who use Mars coordinates, Baidu coordinates and WGS84 coordinates data. The following takes AutoNavi POI data as an example to explain in detail the process of converting the GCJ02 coordinate system to the WGS84 coordinate system by the plug-in.

  • Install plugin

Open QGIS, click the menu [Plugins] -> [Manage and install plug-ins...].
Insert picture description here

In the pop-up plug-in management dialog box, enter "geohey", find the "GeoHey Toolbox" plug-in, click the [install plug-in] button at the bottom right, and close the dialog box after the installation is complete.
Insert picture description here

Click the menu [Processing] -> [Toolbox] to open the processing toolbox panel.
Insert picture description here
Scroll down to the "GeoHey" group, expand [GeoHey] -> [China Coord Convert], you can see the conversion tool between Mars coordinate system (GCJ02), Baidu coordinate system (BD09) and WGS84 coordinate system, according to the data situation Select the corresponding tool for coordinate conversion.
Insert picture description here

  • AutoNavi Data to WGS Coordinates
    The POI data downloaded from AutoNavi API is very rich in attributes. In order to simplify the operation, this article extracts 6 attribute fields of POI name, latitude and longitude, province, city, county, and address information, which are stored in a text file separated by commas. , The screenshot is as follows:
    Insert picture description here
    First, you need to import the text file into QGIS. Click the menu [Layer] -> [Data Source Manager] to open the data source management dialog box and switch to the [Delimited Text File] tab. Enter the path of the file in the [File name], select [Custom Separator] in [File Format], check the [Comma] checkbox on the right, and you can see the file reading result in the [Data Sample] below . Specify the abscissa and ordinate fields in [Geometric Definition] as lng and lat respectively.
    Insert picture description here

After clicking the [Add] button, close the dialog box and return to QGIS, you can see the imported points are displayed in the map window.
Insert picture description here
Open Google Maps and overlay it, and confirm whether the imported POI point position has shifted. (For how to open the Google base map, please refer to "Talking about XYZTiles" ) As you can see from the picture, the POI point position downloaded by AutoNavi API is consistent with the Google base map without any offset. It can be seen that the Google Map China area and Gao The German maps use the same coordinates, all in the GCJ02 coordinate system.

Insert picture description here
Close the Google basemap and open the OpenStreetMap map. The position deviation of the same point from the basemap is very obvious. Therefore, if you want to use OpenStreetMap as the basemap, you must go through the coordinate conversion from GCJ02 to WGS84.
Insert picture description here
In the [Processing Toolbox], find [GeoHey] -> [China Coord Convert] in turn, double-click [GCJ02 to WGS], and the parameter setting dialog box will pop up. Select "beijing" for the input layer, and the output layer can be stored in the GeoPackage file or not filled in. At this time, QGIS will create a temporary layer to store the output result. Click the [Run] button to perform coordinate conversion.
Insert picture description here

After the coordinate conversion calculation is completed, close the dialog box, return to the QGIS map window, and set the original POI layer to be invisible. It can be seen that after the coordinate conversion, the position of the POI point basically matches the base map of OpenStreetMap.
Insert picture description here

summary

GeoHey Toolbox is small in size and easy to operate. It provides convenience for the conversion between Mars coordinates, Baidu coordinates and WGS84 coordinate system. It is a practical plug-in that is worthy of Amway. It is recommended that you use it when you need to perform coordinate conversion.

This is the end of the introduction to the conversion between Mars coordinates, Baidu coordinates and WGS84 coordinates using the QGIS plugin. I will continue to organize and share useful plug-ins in my study and work.


Wu Jianling

August 15, 2020


Copyright Notice


This article welcomes reprinting, please indicate the source when reprinting.


Insert picture description here

Guess you like

Origin blog.csdn.net/QGISClass/article/details/108139699