坐標轉換一些
阿新 • • 發佈:2019-04-06
urn 經緯度 轉化 pre 高德地圖 測繪 坐標系 表示 over
http://rovertang.com/labs/tileindex/
關於中國的經緯度
國內的經緯度有三套系統:
- WGS84:為一種大地坐標系,也是目前廣泛使用的GPS全球衛星定位系統使用的坐標系。
- GCJ02:又稱火星坐標系,是由中國國家測繪局制訂的地理信息系統的坐標系統。由WGS84坐標系經加密後的坐標系。
- BD09:為百度坐標系,在GCJ02坐標系基礎上再次加密。其中bd09ll表示百度經緯度坐標,bd09mc表示百度墨卡托米制坐標。
使用OpenStreetMap的坐標為WGS84;使用高德地圖、騰訊地圖的坐標為GCJ02;使用百度地圖的坐標為BD09;谷歌地圖和Bing地圖的中國部分采用了高德地圖的數據,所以坐標為GCJ02。
WGS84的坐標轉化為GCJ02的坐標是單向的,即WGS84的坐標能夠準確地變換為GCJ02坐標;但GCJ02坐標轉換為WGS84時會存在精度損失。
GCJ02的坐標和BD09的坐標轉換是雙向的,轉換規則可以參考下面的python代碼:
import math
x_pi = 3.14159265358979324 * 3000.0 / 180.0
def amapcoor2bmapcoor(amap_lon, amap_lat):
x = amap_lon
y = amap_lat
z = math.sqrt(x * x + y * y) + 0.00002 * math.sin(y * x_pi)
theta = math.atan2(y, x) + 0.000003 * math.cos(x * x_pi)
bmap_lon = z * math.cos(theta) + 0.0065
bmap_lat = z * math.sin(theta) + 0.006
return (bmap_lon, bmap_lat)
def bmapcoor2amapcoor(bmap_lon, bmap_lat):
x = bmap_lon - 0.0065
y = bmap_lat - 0.006;
z = math.sqrt(x * x + y * y) - 0.00002 * math.sin(y * x_pi);
theta = math.atan2(y, x) - 0.000003 * math.cos(x * x_pi);
amap_lon = z * math.cos(theta);
amap_lat = z * math.sin(theta);
return (amap_lon, amap_lat)
https://github.com/geometalab/pyGeoTile
坐標轉換一些