Article copyright by the author Xiaohui Li is and the blog park, if reproduced please clearly indicate the source: http://www.cnblogs.com/naaoveGIS/
1. Background
Data display based on Baidu Map is a common scenario in the current project, but because Baidu Map is based on the BD09 coordinate system, GPS coordinates (WGS84) or other common standard coordinates can not be accurately displayed on the map, but in the case of Internet online, Baidu provides the WGS84 latitude and longitude to convert Baidu latitude and longitude coordinates of the API, here no longer study it (offline case also has a special method to solve). Here, we discuss how to get Baidu on Baidu coordinate data inversion into WGS84 coordinates.
At present, there are three kinds of common methods to solve this problem, namely algorithm approximation, error approximation and grid approximation method.
2. Algorithm approximation method
Baidu map coordinate system background for the first use of the National Bureau of GCJ-02, the location of the first encryption, and then use its own BD-09 to carry out two encryption measures. Therefore, based on the approximation of the algorithm, it is also the reverse solution step: First convert the BD09 coordinates into GCJ02 coordinates, and then the GCJ02 coordinates back to the WGS84 coordinates.
The following is a detailed code based on the inverse of the algorithm:
3. Error approximation method
A point for Baidu coordinates point, assuming at this time we regard it as a WGS84 coordinate point A1, using Baidu to provide online WGS84 coordinates converted to Baidu latitude and longitude coordinate system API, can get A1 ' Baidu coordinates, at this time A1 ' and A1 coordinate between the difference is L. If the Baidu map in the 2L range of coordinates its reversal error is roughly the same, then we will be the real Baidu coordinates a l standard deviation of the linear plus minus a ', the last a ' is Baidu coordinates a reversal of the resulting WGS84 coordinates.
The detailed code is as follows:
4. Grid approximation algorithm
This method I described in detail in my previous blog: http://www.cnblogs.com/naaoveGIS/p/5342177.html.
The process is roughly:
A. Divide the specified range by 100M (or smaller) into several grids.
B. Establish the correspondence between WGS84 coordinates and Baidu coordinates in the four-corner coordinates of each grid.
C. Determine which grid the Baidu point is to be converted to, and get the WGS84 coordinates corresponding to the grid's four-corner coordinates.
This point is converted after the grid's weight is calculated with its WGS84 coordinates.
5. Comparison of errors
These three methods are approximate, the error is unavoidable, the error of the three kinds of algorithms to do a preliminary statistics, as follows:
First, the error approximation method and the algorithm approximation method are compared, and the average error of the algorithm is above 10M, in which the approximation method is slightly more accurate than the error approximation method.
And the grid method is a kind of error is very stable method, with 100M grid division as an example, the error is centimeter-level, the following:
6. Summary
When the accuracy requirement is not high, and the rapid deployment is needed, the first push algorithm approaches. The mesh approximation method is still required when high-precision methods are required.
-----Welcome reprint, but retain the copyright, please indicate the source in obvious place: http://www.cnblogs.com/naaoveGIS/
If you feel that this article has really helped you, you can sweep it for a small reward and encouragement, thank you ^_^
A brief talk on the three kinds of ideas of Baidu coordinate reversal to WGS84