问题描述
我试图用纬度经度和高度(海拔)来计算两点之间的距离。我正在使用euklides公式来获得距离:
D =√((Long1-Long2)²+(Lat1-Lat2)²+(Alt1-Alt2)²)
我的分数是地理坐标,而高度是我的海拔高度。
我只有lat和lng,我使用GOOGLE API高程来获取我的高度。
我正在开发一个计算我的旅行距离的应用程序在我的滑雪板上)。我所使用的每一个应用程序,都可以随着高度的距离而前往。像#Endomondo或#Garmin我无法在2D空间中得到我的距离,因为真正的距离将与我返回的距离有所不同。
哪个公式将是最好的计算我的距离?包括海拔高度。
我正在使用PostGis在Python中编写我的应用程序。
p>您可以通过将坐标从Polar(long,lat,alt)转换为笛卡尔坐标(x,y,z)来获得正确的计算:
- 让
polar_point_1 =(long_1,lat_1,alt_1)
和polar_point_2 =(long_2,lat_2,alt_2)
/ li>
-
通过使用以下公式将每个点转换为笛卡尔等值:
x = alt * cos(lat)* sin(long)
y = alt * sin(lat)
z = alt * cos(lat)* cos(long)
,您将拥有
p_1 =(x_1,y_1,z_1)
和p_2 =(x_2,y_2,z_2)
分。 -
最后使用欧几里得公式:
dist = sqrt((x_2-x_1)** 2 +(y_2-y_1)** 2 +(z_2-z_1)** 2)
I'm trying to calculate distance between two points, using latitude longitude and altitude (elevation).
I was using euklides formula in order to get my distance:
D=√((Long1-Long2)²+(Lat1-Lat2)²+(Alt1-Alt2)²)
My points are geographical coordinates and ofcourse altitude is my height above the sea.I only have lat and lng, I'm using GOOGLE API Elevation to get my altitude.
I'm developing an application which calculates my traveled distance (on my skis). Every application which I have used, gets distance traveled with included altitude. Like #Endomondo or #Garmin I cannot get my distance in 2D space because true distances are going to vary from the ones I've returned.
Which formula would be the best to calculate my distance ? Ofcourse with included altitude.
I'm writing my app in Python, with PostGis.
You can get the correct calculation by translating your coordinates from Polar (long, lat, alt) to Cartesian (x, y, z):
- Let
polar_point_1 = (long_1, lat_1, alt_1)
andpolar_point_2 = (long_2, lat_2, alt_2)
Translate each point to it's Cartesian equivalent by utilizing this formula:
x = alt * cos(lat) * sin(long) y = alt * sin(lat) z = alt * cos(lat) * cos(long)
and you will have
p_1 = (x_1, y_1, z_1)
andp_2 = (x_2, y_2, z_2)
points respectively.Finally use the Euclidean formula:
dist = sqrt((x_2-x_1)**2 + (y_2-y_1)**2 + (z_2-z_1)**2)
这篇关于使用纬度和高度(海拔)计算两点之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!