|
Archives of the TeradataForumMessage Posted: Tue, 31 May 2005 @ 17:28:32 GMT
Thank you for the incredible information. The summary below is what I will be using. Please review and comment if you can. Thank you again. Your insight is greatly appreciated. -Brian Summary: 1. use Haversine Formula for the greatest accuracy 2. use radians instead of degrees 3. convert degrees to radians by multiplying by PI and dividing by 180 4. use 7,912 miles as the Earth's diameter 5. use (22/7) for PI 6. format distance in miles to 8 decimal places. 7. SQL code of an example: SELECT 35.25927 AS LAT1 ,-81.2238 AS LON1 ,35.22143 AS LAT2 ,-81.1492 AS LON2 ,CAST( (7912* ATAN ( SQRT ( (SIN((LAT2*(22/7)/180-LAT1*(22/7)/180)/2)**2) +(COS(LAT1*(22/7)/180)*COS(LAT2*(22/7)/180)*(SIN((LON2*(22/7)/180-LON1*(22/7)/180)/2)**2)) ) /SQRT ( 1-(SIN((LAT2*(22/7)/180-LAT1*(22/7)/180)/2)**2) +(COS(LAT1*(22/7)/180)*COS(LAT2*(22/7)/180)*(SIN((LON2*(22/7)/180-LON1*(22/7)/180)/2)**2) ) ) ) ) AS DECIMAL(12,8)) AS MILES
| ||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||
Copyright 2016 - All Rights Reserved | ||||||||||||||||||||||||||||||||||||||||||||||||
Last Modified: 15 Jun 2023 | ||||||||||||||||||||||||||||||||||||||||||||||||