目前国内主要有以下三种坐标系:
1. 地球坐标WGS84:为一种大地坐标系,也是目前广泛使用的GPS全球卫星定位系统使用的坐标系;
- 国际标准,从专业GPS 设备中取出的数据的坐标系
- 国际地图提供商使用的坐标系
2. 火星坐标GCJ02:表示经过国测局加密的坐标。即国测局坐标系
- 中国标准,从国行移动设备中定位获取的坐标数据使用这个坐标系
- 国家规定: 国内出版的各种地图系统(包括电子形式),必须至少采用GCJ-02对地理位置进行首次加密。
3. 百度坐标BD09:为百度坐标系,其中bd09ll表示百度经纬度坐标,bd09mc表示百度墨卡托米制坐标;
- 百度标准,百度 SDK,百度地图,Geocoding 使用
坐标转换代码:
/// <summary> /// 坐标转换 /// </summary> public class PositionUtil { /** * 各地图API坐标系统比较与转换; * WGS84坐标系:即地球坐标系,国际上通用的坐标系。设备一般包含GPS芯片或者北斗芯片获取的经纬度为WGS84地理坐标系, * 谷歌地图采用的是WGS84地理坐标系(中国范围除外); * GCJ02坐标系:即火星坐标系,是由中国国家测绘局制订的地理信息系统的坐标系统。由WGS84坐标系经加密后的坐标系。 * 谷歌中国地图和搜搜中国地图采用的是GCJ02地理坐标系; BD09坐标系:即百度坐标系,GCJ02坐标系经加密后的坐标系; * 搜狗坐标系、图吧坐标系等,估计也是在GCJ02基础上加密而成的。 */ public static double pi = 3.1415926535897932384626; public static double a = 6378245.0; public static double ee = 0.00669342162296594323; /** * 84 to 火星坐标系 (GCJ-02) World Geodetic System ==> Mars Geodetic System * * @param lat * @param lon * @return */ public static Gps gps84_To_Gcj02(double lat, double lon) { if (outOfChina(lat, lon)) { return null; } double dLat = transformLat(lon - 105.0, lat - 35.0); double dLon = transformLon(lon - 105.0, lat - 35.0); double radLat = lat / 180.0 * pi; double magic = Math.Sin(radLat); magic = 1 - ee * magic * magic; double sqrtMagic = Math.Sqrt(magic); dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); dLon = (dLon * 180.0) / (a / sqrtMagic * Math.Cos(radLat) * pi); double mgLat = lat + dLat; double mgLon = lon + dLon; return new Gps(mgLat, mgLon); } /** * * 火星坐标系 (GCJ-02) to 84 * * @param lon * @param lat * @return * */ public static Gps gcj_To_Gps84(double lat, double lon) { Gps gps = transform(lat, lon); double lontitude = lon * 2 - gps.WgLon; double latitude = lat * 2 - gps.WgLat; return new Gps(latitude, lontitude); } /** * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 将 GCJ-02 坐标转换成 BD-09 坐标 * * @param gg_lat * @param gg_lon */ public static Gps gcj02_To_Bd09(double gg_lat, double gg_lon) { double x = gg_lon, y = gg_lat; double z = Math.Sqrt(x * x + y * y) + 0.00002 * Math.Sin(y * pi); double theta = Math.Atan2(y, x) + 0.000003 * Math.Cos(x * pi); double bd_lon = z * Math.Cos(theta) + 0.0065; double bd_lat = z * Math.Sin(theta) + 0.006; return new Gps(bd_lat, bd_lon); } /** * * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 * * 将 BD-09 坐标转换成GCJ-02 坐标 * * @param * bd_lat * @param bd_lon * @return */ public static Gps bd09_To_Gcj02(double bd_lat, double bd_lon) { double x = bd_lon - 0.0065, y = bd_lat - 0.006; double z = Math.Sqrt(x * x + y * y) - 0.00002 * Math.Sin(y * pi); double theta = Math.Atan2(y, x) - 0.000003 * Math.Cos(x * pi); double gg_lon = z * Math.Cos(theta); double gg_lat = z * Math.Sin(theta); return new Gps(gg_lat, gg_lon); } /** * (BD-09)-->84 * @param bd_lat * @param bd_lon * @return */ public static Gps bd09_To_Gps84(double bd_lat, double bd_lon) { Gps gcj02 = PositionUtil.bd09_To_Gcj02(bd_lat, bd_lon); Gps map84 = PositionUtil.gcj_To_Gps84(gcj02.WgLat, gcj02.WgLon); return map84; } public static Boolean outOfChina(double lat, double lon) { if (lon < 72.004 || lon > 137.8347) return true; if (lat < 0.8293 || lat > 55.8271) return true; return false; } public static Gps transform(double lat, double lon) { if (outOfChina(lat, lon)) { return new Gps(lat, lon); } double dLat = transformLat(lon - 105.0, lat - 35.0); double dLon = transformLon(lon - 105.0, lat - 35.0); double radLat = lat / 180.0 * pi; double magic = Math.Sin(radLat); magic = 1 - ee * magic * magic; double sqrtMagic = Math.Sqrt(magic); dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); dLon = (dLon * 180.0) / (a / sqrtMagic * Math.Cos(radLat) * pi); double mgLat = lat + dLat; double mgLon = lon + dLon; return new Gps(mgLat, mgLon); } public static double transformLat(double x, double y) { double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.Sqrt(Math.Abs(x)); ret += (20.0 * Math.Sin(6.0 * x * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0; ret += (20.0 * Math.Sin(y * pi) + 40.0 * Math.Sin(y / 3.0 * pi)) * 2.0 / 3.0; ret += (160.0 * Math.Sin(y / 12.0 * pi) + 320 * Math.Sin(y * pi / 30.0)) * 2.0 / 3.0; return ret; } public static double transformLon(double x, double y) { double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.Sqrt(Math.Abs(x)); ret += (20.0 * Math.Sin(6.0 * x * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0; ret += (20.0 * Math.Sin(x * pi) + 40.0 * Math.Sin(x / 3.0 * pi)) * 2.0 / 3.0; ret += (150.0 * Math.Sin(x / 12.0 * pi) + 300.0 * Math.Sin(x / 30.0 * pi)) * 2.0 / 3.0; return ret; } } public class Gps { private double wgLat; private double wgLon; public Gps(double wgLat, double wgLon) { this.wgLat = wgLat; this.wgLon = wgLon; } public double WgLat { get { return wgLat; } } public double WgLon { get { return wgLon; } } }
附:
中国各地级市的WGS84坐标和BD09坐标(城市名称,WGS84经度,WGS84纬度,BD09经度,BD09纬度)
北京市 116.3829483 39.92246751 116.395645 39.929986
天津市 117.1979271 39.13718049 117.210813 39.14393
石家庄市 114.509603 38.04235708 114.522082 38.048958
唐山市 118.1707801 39.64291916 118.183451 39.650531
秦皇岛市 119.5921352 39.93824647 119.604368 39.945462
邯郸市 114.4702154 36.60303167 114.482694 36.609308
邢台市 114.5081189 37.06310209 114.520487 37.069531
保定市 115.482066 38.87973678 115.49481 38.886565
张家口市 114.8810428 40.80419602 114.893782 40.811188
承德市 117.9211778 40.98463317 117.933822 40.992521
沧州市 116.8514289 38.29139827 116.863806 38.297615
廊坊市 116.6911038 39.51170339 116.703602 39.518611
衡水市 115.6738941 37.74008784 115.686229 37.746929
太原市 112.5380422 37.88379374 112.550864 37.890277
大同市 113.2769374 40.10677631 113.290509 40.113744
阳泉市 113.5563322 37.86294266 113.569238 37.869529
长治市 113.1070129 36.1958097 113.120292 36.201664
晋中市 112.7254763 37.68691822 112.738514 37.693362
运城市 110.9944692 35.03394366 111.006854 35.038859
忻州市 112.7147904 38.45466773 112.727939 38.461031
临汾市 111.5261148 36.0938677 111.538788 36.099745
吕梁市 111.1302033 37.5208362 111.143157 37.527316
通辽市 122.2484252 43.62513511 122.260363 43.633756
鄂尔多斯市 109.9816249 39.8091339 109.993706 39.81649
沈阳市 123.4201318 41.80029962 123.432791 41.808645
大连市 121.582058 38.94182003 121.593478 38.94871
鞍山市 122.9956133 41.11117124 123.007763 41.118744
丹东市 124.3263586 40.12131952 124.338543 40.129023
营口市 122.2217861 40.66080003 122.233391 40.668651
阜新市 121.649007 42.01099772 121.660822 42.01925
辽阳市 123.1600379 41.26549554 123.172451 41.273339
葫芦岛市 120.8489946 40.73591245 120.860758 40.74303
长春市 125.3005988 43.89017548 125.313642 43.898338
吉林市 126.5523564 43.86383753 126.564544 43.871988
白山市 126.4234849 41.93727644 126.435798 41.945859
延边朝鲜族自治州 129.4723517 42.88789059 129.485902 42.896414
哈尔滨市 126.6451733 45.76544049 126.657717 45.773225
七台河市 131.0046751 45.76714899 131.019048 45.775005
牡丹江市 129.5945193 44.58045598 129.608035 44.588521
上海市 121.4769086 31.24514472 121.487899 31.249162
南京市 118.7662822 32.05354757 118.778074 32.057236
无锡市 120.2944328 31.56573156 120.305456 31.570037
徐州市 117.1757267 34.2670588 117.188107 34.271553
常州市 119.9707196 31.76707138 119.981861 31.771397
苏州市 120.6092168 31.31429505 120.619907 31.317987
南通市 120.8629705 32.0111502 120.873801 32.014665
连云港市 119.1616254 34.59680136 119.173872 34.601549
淮安市 119.0181179 33.60224879 119.030186 33.606513
盐城市 120.1374729 33.37492893 120.148872 33.379862
扬州市 119.4157639 32.4044722 119.427778 32.408505
镇江市 119.4439137 32.20037945 119.455835 32.204409
泰州市 119.9084428 32.47192909 119.919606 32.476053
宿迁市 118.2849395 33.94716703 118.296893 33.95205
杭州市 120.2084017 30.25538801 120.219375 30.259244
宁波市 121.5684199 29.88179679 121.579006 29.885259
温州市 120.6800592 28.00034536 120.690635 28.002838
嘉兴市 120.7495274 30.7705361 120.760428 30.773992
湖州市 120.1260109 30.8736684 120.137243 30.877925
绍兴市 120.58187 29.99910119 120.592467 30.002365
金华市 119.6414157 29.09970554 119.652576 29.102899
舟山市 122.1591875 30.03201564 122.169872 30.03601
台州市 121.4296671 28.66531569 121.440613 28.668283
合肥市 117.2706354 31.86317488 117.282699 31.866942
芜湖市 118.3722526 31.36173292 118.384108 31.36602
蚌埠市 117.344748 32.9254047 117.35708 32.929499
淮南市 117.0065456 32.63916701 117.018639 32.642812
淮北市 116.7794575 33.95570631 116.791447 33.960023
铜陵市 117.8076656 30.93693679 117.819429 30.94093
安庆市 117.0467027 30.53454529 117.058739 30.537898
黄山市 118.2820153 29.73070239 118.29357 29.734435
滁州市 118.312703 32.31316001 118.32457 32.317351
宿州市 116.9766584 33.6326485 116.988692 33.636772
六安市 116.4936132 31.75156567 116.505253 31.755558
亳州市 115.7759779 33.86638677 115.787928 33.871211
宣城市 118.7404037 30.9481056 118.752096 30.951642
福州市 119.3188313 26.04434453 119.330221 26.047125
厦门市 118.0924611 24.48553467 118.103886 24.489231
莆田市 119.0662758 25.44543523 119.077731 25.44845
三明市 117.6308169 26.2681161 117.642194 26.270835
泉州市 118.5893891 24.89875812 118.600362 24.901652
漳州市 117.6648956 24.51381863 117.676205 24.517065
南平市 118.1704412 26.6406115 118.181883 26.643626
龙岩市 117.0065736 25.07581221 117.017997 25.078685
宁德市 119.530955 26.65394958 119.542082 26.656527
南昌市 115.8822411 28.68661008 115.893528 28.689578
九江市 115.988382 29.71585829 115.999848 29.71964
新余市 114.935664 27.82009276 114.947117 27.822322
鹰潭市 117.0236957 28.23887493 117.03545 28.24131
宜春市 114.3882596 27.8081182 114.400039 27.81113
上饶市 117.9440402 28.45466525 117.955464 28.457623
济南市 117.0124189 36.6768069 117.024967 36.682785
青岛市 120.3728285 36.09879877 120.384428 36.105215
淄博市 118.046657 36.79782272 118.059134 36.804685
枣庄市 117.2669286 34.80299076 117.279305 34.807883
东营市 118.5718496 37.48061017 118.583926 37.487121
烟台市 121.2979124 37.52988565 121.309555 37.536562
潍坊市 119.1300836 36.70994728 119.142634 36.716115
济宁市 116.5889971 35.39669533 116.600798 35.402122
泰安市 117.0767403 36.18217183 117.089415 36.188078
威海市 122.0825063 37.52139851 122.093958 37.528787
日照市 119.4951652 35.41444366 119.50718 35.420225
莱芜市 117.6723267 36.22745932 117.684667 36.233654
临沂市 118.3286138 35.06670794 118.340768 35.072409
德州市 116.3159123 37.45383979 116.328161 37.460826
聊城市 115.9747951 36.44940566 115.986869 36.455829
滨州市 117.95604 37.39833552 117.968292 37.405314
菏泽市 115.450932 35.25680243 115.46336 35.26244
郑州市 113.6371083 34.75161213 113.649644 34.75661
开封市 114.339273 34.79651431 114.351642 34.801854
洛阳市 112.434743 34.65227383 112.447525 34.657368
平顶山市 113.2880479 33.74097224 113.300849 33.745301
安阳市 114.3393058 36.10398736 114.351807 36.110267
新乡市 113.900402 35.30153694 113.91269 35.307258
濮阳市 115.0141781 35.74768171 115.026627 35.753298
许昌市 113.8229595 34.0219657 113.835312 34.02674
漯河市 114.0336999 33.57137452 114.046061 33.576279
三门峡市 111.1686334 34.77853801 111.181262 34.78332
南阳市 112.5305105 33.00746834 112.542842 33.01142
商丘市 115.6299343 34.43383015 115.641886 34.438589
信阳市 114.0731916 32.12419496 114.085491 32.128582
周口市 114.6422049 33.6195509 114.654102 33.623741
驻马店市 114.0368235 32.97860135 114.049154 32.983158
武汉市 114.3042835 30.57729474 114.3162 30.581084
黄石市 115.0386768 30.21287453 115.050683 30.216127
十堰市 110.7893098 32.6334381 110.801229 32.636994
宜昌市 111.298707 30.72934143 111.310981 30.732758
襄阳市 112.1639119 32.09069173 112.176326 32.094934
鄂州市 114.8839485 30.38145398 114.895594 30.384439
荆门市 112.2050996 31.03857749 112.21733 31.042611
孝感市 113.9238318 30.92408934 113.935734 30.927955
荆州市 112.2297041 30.32889363 112.241866 30.332591
黄冈市 114.8949677 30.44311821 114.906618 30.446109
咸宁市 114.2882535 29.87696533 114.300061 29.880657
随州市 113.366627 31.71387971 113.379358 31.717858
恩施土家族苗族自治州 109.50612 30.30559654 109.517433 30.308978
长沙市 112.9672125 28.21124421 112.979353 28.213478
湘潭市 112.9235849 27.83289987 112.935556 27.835095
岳阳市 113.1336825 29.37487962 113.146196 29.378007
常德市 111.6417623 29.00913869 111.653718 29.012149
益阳市 112.3543449 28.58506907 112.366547 28.588088
永州市 111.6029131 26.43344843 111.614648 26.435972
广州市 113.2957405 23.11688998 113.30765 23.120049
深圳市 114.0144792 22.54251804 114.025974 22.546054
珠海市 113.5508686 22.25383348 113.562447 22.256915
汕头市 116.7175741 23.38072763 116.72865 23.383908
佛山市 113.1219862 23.03196382 113.134026 23.035095
江门市 113.066104 22.57214574 113.078125 22.575117
肇庆市 112.4679294 23.07526691 112.479653 23.078663
惠州市 114.3992077 23.10993497 114.410658 23.11354
河源市 114.70248 23.75410434 114.713721 23.757251
阳江市 111.9655403 21.8679509 111.97701 21.871517
清远市 113.0287943 23.69532049 113.040773 23.698469
东莞市 113.7517961 23.03949441 113.763434 23.043024
中山市 113.4100438 22.54195369 113.42206 22.545178
揭阳市 116.3683389 23.54426422 116.379501 23.547999
南宁市 108.2868261 22.80311487 108.297234 22.806493
柳州市 109.4112592 24.32582371 109.422402 24.329053
桂林市 110.2499403 25.25953734 110.26092 25.262901
梧州市 111.2938 23.48216104 111.305472 23.485395
北海市 109.1117939 21.4694091 109.122628 21.472718
防城港市 108.3413644 21.61372497 108.351791 21.617398
钦州市 108.6285605 21.9703956 108.638798 21.97335
贵港市 109.6030432 23.10017073 109.613708 23.103373
玉林市 110.1406843 22.64041407 110.151676 22.643974
百色市 106.621878 23.89853056 106.631821 23.901512
河池市 108.0592702 24.6959749 108.069948 24.699521
来宾市 109.2209784 23.73805691 109.231817 23.741166
崇左市 107.3466443 22.41237227 107.357322 22.415455
海口市 110.3199777 20.01794407 110.330802 20.022071
三亚市 109.5121878 18.25347454 109.522771 18.257776
重庆市 106.520369 29.54142688 106.530635 29.544606
成都市 104.0589972 30.67605281 104.067923 30.679943
泸州市 105.433849 28.89300587 105.44397 28.89593
德阳市 104.3932551 31.12718397 104.402398 31.13114
绵阳市 104.6963031 31.50112625 104.705519 31.504701
遂宁市 105.5549576 30.55418235 105.564888 30.557491
内江市 105.0632353 29.59633457 105.073056 29.599462
乐山市 103.7521933 29.59747809 103.760824 29.600958
眉山市 103.8328786 30.05764059 103.84143 30.061115
广安市 106.6253814 30.46088588 106.63572 30.463984
达州市 107.4838886 31.2104181 107.494973 31.214199
巴中市 106.747209 31.86559919 106.757916 31.869189
阿坝藏族羌族自治州 102.2204967 31.90177216 102.228565 31.905763
甘孜藏族自治州 101.9612982 30.0516587 101.969232 30.055144
凉山彝族自治州 102.2516655 27.88961849 102.259591 27.892393
贵阳市 106.6988611 26.62763539 106.709177 26.629907
六盘水市 104.8429745 26.58978635 104.852087 26.591866
遵义市 106.9208789 27.69780725 106.93126 27.699961
安顺市 105.9185162 26.22583343 105.92827 26.228595
毕节市 105.2907146 27.30016878 105.300492 27.302612
铜仁市 109.1850289 27.72381678 109.196161 27.726271
黔西南布依族苗族自治州 104.8915385 25.09255464 104.900558 25.095148
黔东南苗族侗族自治州 107.9747889 26.5812105 107.985353 26.583992
黔南布依族苗族自治州 107.5125141 26.26194189 107.523205 26.264536
昆明市 102.7066245 25.04631918 102.714601 25.049153
曲靖市 103.7740693 25.51750984 103.782539 25.520758
玉溪市 102.5372696 24.36752973 102.545068 24.370447
丽江市 100.2220454 26.87265951 100.229628 26.875351
普洱市 100.9722776 22.78606441 100.980058 22.788778
楚雄彝族自治州 101.5214056 25.06335748 101.529382 25.066356
红河哈尼族彝族自治州 103.3755279 23.36434992 103.384065 23.367718
西双版纳傣族自治州 100.7953607 22.00653226 100.803038 22.009433
大理白族自治州 100.2161415 25.59368466 100.223675 25.5969
德宏傣族景颇族自治州 98.58274269 24.43848228 98.589434 24.44124
拉萨市 91.10375613 29.65952005 91.111891 29.662557
西安市 108.9418135 34.27369242 108.953098 34.2778
铜川市 108.956687 34.90373337 108.968067 34.908368
宝鸡市 107.1592651 34.35967182 107.170645 34.364081
咸阳市 108.6962758 34.34100987 108.707509 34.345373
渭南市 109.4721583 34.49760965 109.483933 34.502358
延安市 109.4885995 36.5972292 109.50051 36.60332
汉中市 107.0343012 33.07772872 107.045478 33.081569
榆林市 109.7339042 38.27268744 109.745926 38.279439
商洛市 109.9228475 33.86928303 109.934208 33.873907
兰州市 103.8144528 36.05825897 103.823305 36.064226
嘉峪关市 98.27464508 39.79539206 98.281635 39.802397
白银市 104.1620481 36.54035923 104.171241 36.546682
武威市 102.6318978 37.92701915 102.640147 37.933172
平凉市 106.6780967 35.544722 106.688911 35.55011
酒泉市 98.50131994 39.73468105 98.508415 39.741474
庆阳市 107.6330531 35.7210705 107.644227 35.726801
定西市 104.61746 35.58072779 104.626638 35.586056
甘南藏族自治州 102.9091177 34.98764214 102.917442 34.992211
西宁市 101.759532 36.6345692 101.767921 36.640739
海东市 102.0767251 36.5112456 102.085207 36.51761
银川市 106.1956153 38.49585945 106.206479 38.502621
固原市 106.2746133 36.015488 106.285268 36.021523
和田地区 79.92193462 37.11088529 79.930239 37.116774