python的坐标转换程序
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 23 18:57:18 2016
@author: Administrator
"""
import numpy as np
PI=3.1415926
a=6378137.0
b=6356752.3142;
e=np.sqrt(a*a-b*b)/a
c=a*a/b
choice=input('choice a coordinate\n[1]geodetic
ccoordinate[2]rectangular coordinate\nnumber=')
if choice==1:
B=input('B=')
L=input('\nL=')
H=input('\nH=')
W=np.sqrt(1-e*e*np.sin(B)*np.sin(B))
N=a/W
X=(N+H)*np.cos(B)*np.cos(L)
Y=(N+H)*np.cos(B)*np.sin(L)
Z=(N*(1-e*e)+H)*np.sin(B)
print('X=',X)
print('\nY=',Y)
print('\nZ=',Z)
else:
X=input('X=\n')
Y=input('Y=\n')
Z=input('Z=\n')
#e1=((a*a-b*b)/b*b)
m=Z/np.sqrt(X*X+Y*Y)
B0=np.arctan(m)
n=Z/np.sqrt(X*X+Y*Y)
P=c*e*e/np.sqrt(X*X+Y*Y)
k=1+(a*a-b*b)/(b*b)
t=m+P*n/np.sqrt(k+n*n)#现在为t1,之后代替t2,t3...
B=np.arctan(t)
W=np.sqrt(1-e*e*np.sin(B)*np.sin(B))
N=a/W
H=Z/np.sin(B) -
N*(1-e*e);
# for
(i=1;fabs(B-B0)>10E-10;i++){c
#
B0=B;
# n=t;
# t=m+P*n/sqrt(k+n*n);#迭代
#B=np.arctan(t)}
#W=sqrt(1-e*e*sin(B)*sin(B))
N=a/W
while(np.fabs(B-B0)>10E-10):
B0=B
n=t
t=m+P*n/np.sqrt(k+n*n)
B=np.arctan(t)
W=np.sqrt(1-e*e*np.sin(B)*np.sin(B))
N=a/W
L=np.arctan2(Y,X)
H=np.sqrt((X*X+Y*Y)/np.cos(B)-N)
B=180.0*B/PI
L=180.0*L/PI
print('B=',B,'\nL=',L,'\nH=',H)
python最近是一门挺火的语言,所以试试了