Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
697 views
in Technique[技术] by (71.8m points)

python - Calculating distance between two points using latitude longitude and altitude (elevation)

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)2+(Lat1-Lat2)2+(Alt1-Alt2)2)

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can calculate distance between flat coordinates in, say, meters by using geopy package or Vincenty's formula, pasting coordinates directly. Suppose the result is d meters. Then the total distance travelled is sqrt(d**2 + h**2) where h is the change in elevation in meters.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...