Usage Note 3973: Calculating the distance between points from map coordinates
Unprojected SAS map data sets have X and Y coordinates represented as
longitude and latitude in radians. Mileage between two points in a map
data set may be calculated as follows:
Assume the longitude and latitude of point 1 are represented by X1 and
Y1, while point 2 is represented by X2 and Y2. The distance is:
DISTANCE = 4000*ARCOS(arc)
where:
arc = SIN(Y2)*SIN(Y1) + COS(Y2)*COS(Y1)*COS(X2-X1)
* The longitude for the western hemisphere should be negative, and the
eastern should be positive. The latitude in the northern
hemisphere should be positive, and the southern should be negative.
* If your coordinates are in degrees/minutes/seconds, first use this
equation to calculate a real number from degrees/minutes/seconds
and then convert to radians:
VALUE = (degrees) + (minutes/60) + (seconds/3600);
pi=4*atan(1);
radians=value/(180/pi);
Another formula is the Great Circle Distance Formula which will
calculate the distance in miles between two pairs of latitude/longitude
values specified in radians:
Dist = 3949.99 * arcos(sin(Y1) * sin(Y2) +
cos(Y1) * cos(Y2) *
cos(X1 - X2));
This formula more closely compensates for the curvature of the Earth.
Operating System and Release Information
| SAS System | SAS/GRAPH | AIX | 8 TS M0 | |
| Microsoft Windows NT Workstation | 8 TS M0 | |
| Microsoft Windows 95/98 | 8 TS M0 | |
| OpenVMS VAX | 8 TS M0 | |
| OS/2 | 8 TS M0 | |
| 64-bit Enabled Solaris | 8 TS M0 | |
| Solaris | 8 TS M0 | |
| CMS | 8 TS M0 | |
| 64-bit Enabled HP-UX | 8 TS M0 | |
| HP-UX | 8 TS M0 | |
| z/OS | 8 TS M0 | |
| Tru64 UNIX | 8 TS M0 | |
| 64-bit Enabled AIX | 8 TS M0 | |
| OpenVMS Alpha | 8 TS M0 | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
| Type: | Usage Note |
| Priority: | |
| Topic: | SAS Reference ==> Procedures ==> GMAP
|
| Date Modified: | 2000-12-14 15:35:52 |
| Date Created: | 2000-12-14 15:35:52 |