| Advanced Search | ||||||||||||||
| |||||||||||||||
Frequently Asked Questions: FAQ about GPSTopic
Distance between two positionsQuestion: I have two positions in Lat and Lon, and want to find out the distance between them. Answer: For short distances, one can take the line of sight between the two points: Say you have two points: (Lat1, Lon1) and (Lat2 and Lon2) which are not too far (kilometers) from each other. - Take the differences: --------------------------- dLat = Lat1 - Lat2 dLon = Lon1 - Lon2 --------------------------- - Convert these to meters: One degree of Latitude has 111'199.233 Meters: ------------------------------------- dMLat = dLat * 111'199.233 ------------------------------------- One degree of Longitude is dependent on the Latitude. One degree Longitude has 111'199.233 * cosine ( Latitude ) Meters. Please note that usually, the cosine library function expects it argument in radians, rather than degrees, so conversion might be necessary. ------------------------------------------------------------------------ dMLon = dLon * ( 111'199.233 * cos ( Lat * PI / 180 ) ) ------------------------------------------------------------------------ - We now have the differences in meters in north/south direction dMLat, and in east/west direction dMLon. Using Pythagoras, we get the true distance -------------------------------------------------- D = square_root( dMLon2 + dMLat2 ) -------------------------------------------------- Keep in mind that this is only true for relatively short distances. For longer distances, the "Great Circle" algorithm can be used, which is documented in literature. |
| ||||||||||||||
| |||||||||||||||