在网上搜集整理有关高斯克吕格投影的代码并用 python 改写。
from math import *
p = 180.0 / pi * 3600
def deg2rad(deg):
dms = deg*3600/p
return dms
def gauss_zhengsuan(B,L,L0): # 纬度、经度、中央经线经度
l = L-L0
l = deg2rad(l) #经度
B = deg2rad(B) #纬度
a = 6378245.0 # Beijing1954 Krasovsky_1940',6378245.0,298.3
f = 1.0/298.3
b = a - a*f
c = a**2/b
e = sqrt(a**2 - b**2)/a
e1 = sqrt(a**2 - b**2)/b
p = 3600*180/pi
Beta0 = 1 - (3.0/4)*e1**2 + (45.0/64)*e1**4 - (175.0/256)*e1**6 + (11025.0/16384)*e1**8
Beta2 = Beta0-1
Beta4 = (15.0/32)*e1**4 - (175.0/384)*e1**6 + (3675.0/8192)*e1**8
Beta6 = -(35.0/96)*e1**6 + (735.0/2048)*e1**8
Beta8 = (315.0/1024)*e1**8
Xb0 = c*(Beta0*(B) + sin(B)*(Beta2*cos(B) + Beta4*cos(B)**3 + Beta6*cos(B)**5 + Beta8*cos(B)**7))
Np = a/sqrt(1 - (e*sin(B))**2)
m0 = l*cos(B)
t = tan(B)
in2 = (e1)**2*cos(B)**2
X = Xb0 + (1.0/2)*Np*t*m0**2 + (1.0/24)*(5-t**2 + 9.0*in2 + 4.0*in2**2)*Np*t*m0**4 + (1.0/720)*(61 - 58.0*t**2)*Np*t*m0**6.0
Y = Np*m0 + (1.0/6)*(1 - t**2 + in2)*Np*m0**3 + (1.0/120)*(5 - 18.0*t**2 + t**4 + 14.0*in2 - 58.0*t**2*in2)*Np*m0**5 + 500000
return Y,X # X表示纵坐标,Y表示横坐标
result = gauss_zhengsuan(32.34, 120.123, 120)