```Date: Thu, 25 Feb 2010 11:56:05 -0500 Reply-To: "Adam B. Troy" Sender: "SPSSX(r) Discussion" From: "Adam B. Troy" Subject: Lat/Long Distance Calculation Syntax Content-Type: multipart/alternative; Hi all, I'm trying to refine a syntax to calculate the distance between a pair of latitude/longitudes. The syntax below is from Ray Levesque's site, but as the distance between points increases, the error of the calculation greatly increases, often undestimating by hundreds of miles as the distance exceeds 1000+ miles. I am using decimal degree formats (e.g., lat 40.852931; long -74.109250 ). Any info would be greatly appreciated to increase the accuracy of this calculation. --Adam compute theta = long2 - long1. compute d1 = (sin((artan(1)/45)*(lat2)) * sin((artan(1)/45)*(lat1))) + (cos((artan(1)/45)*(lat2)) * cos((artan(1)/45)*(lat1)) * cos((artan(1)/45)*(theta))). if range(d1,-1,1) d2 = 2*artan(1) - arsin(d1) . compute d3 = (45/artan(1))*(d2). compute distmile = d3 * 60 * 1.1515 . compute distkm = distmile * 1.609344. Execute. [text/html] ```

Back to: Top of message | Previous page | Main SPSSX-L page