Topics:
DVR
nvrec
Mplayer
Links
Misc
Commands
Humor
New user
uploaded files
|
(catalina22)-> latitude and longitude to distance formula |
submited by Russell Fri 12 Aug 05 Edited Tue 11 Sep 07 |
Formula for the distance between to points given in latitude and longitude
Except for some reason, this formula does not work for me..
I used this (a1,a2,b1,b2) =Latitude,longitude points a,b *IN RADIANS* $r=Radius of earth in desired units:
return sqrt(($a1-$b1)**2 + ($a2-$b2)**2)*$r;
This formula WILL BE WRONG for large distances, since it does not use a great circle route. (shortest route from NY to japan is via Alaska )
For my needs ( find the closest zip code to a given code) this formula is fine.
Free source of Zip code to latitude and longitude data
Avoid a pitfall that hit me if you use this data in perl. This database has leading zeros on negative values. Perl has a irritating habit of considering these to be Octal numbers ( not decimal numbers) This caused a lot of gibberish output. so do a $x=~s/-0/-/g; on the values before you treat them as numbers.
|
Add comment or question...:
|