我下载了气象数据,其中包含经度(十进制)、纬度(十进制)和高程(米)值。没有关于使用的坐标系统的信息。我该如何将其转换为笛卡尔坐标?我的尝试如下,但我的问题是找到正确的公式。
def cartesian(self,longitude,latitude, elevation):
R = 6378137.0 + elevation # relative to centre of the earth
X = R * math.cos(longitude) * math.sin(latitude)
Y = R * math.sin(longitude) * math.sin(latitude)
Z = R * math.cos(latitude)
def cartesian3(self,longitude,latitude, elevation):
X = longitude * 60 * 1852 * math.cos(latitude)
Y = latitude * 60 * 1852
Z = elevation
return X,Y,Z
这里有一个回答(链接)由Daphna Shezaf提供,使用不同的公式。然而,这个回答没有使用高程数据。 我很感激如果有人能解释一下,转换经纬度时是否应该考虑高程?正确的公式是什么?我试着比较了我的代码在这个网站上使用特定的经、纬、高进行转换,但我的两种方法得到的结果与网站得到的结果相差甚远。
更新
我想分享我的问题的解决方案。我在Python中实现了来自Matlab的lla2ecef函数作为(链接)。它可以将弧度经度、纬度和海拔高度(以米为单位)转换为笛卡尔坐标。我只需要将经度和纬度转换为弧度,如果它们是十进制的,就像这样:
latitude = (lat * math.pi) / 180 #latitude in radian, and lat in decimal
为了验证我的计算结果,我将转换结果与上述网站(网站)以及此网站进行了比较,并得到了几乎相同的结果。
注意:如果你认为地球是个球体,你可以使用
def cartesian
(我已更新它;感谢Sasha的更正)。如果你认为地球是椭球体(WGS 84大地测量系统),你可以按照lla2ecef
中所述实现转换。而def cartesian
则适用于制图投影(感谢rodrigo)。
def cartesian(self,longitude,latitude, elevation): R = 6378137.0 + elevation # 相对于地心的高度 X = R * math.cos(longitude) * math.cos(latitude) Y = R * math.sin(longitude) * math.cos(latitude) Z = R * math.sin(latitude)
- Ali