Date: Wed, 9 Apr 1997 08:21:45 +0200 Willem Dekker "SAS(r) Discussion" Willem Dekker Re: Mapping Questions <3342344A.43FF@ga.unc.edu> text/plain; charset="us-ascii"

>Hi all, > I've got a couple of questions relating to mapping in SAS, and >hope someone out there can help. > > First, does anyone have a good formula for calculating distance >between two points? Currently, I'm using the following, but would >appreciate a formula that has a little more solid cartographical >foundation: > >longlen=69*(cos(lat*arcos(-1)/180)); >y1len=69*(cos(lat1*arcos(-1)/180)); >distx=69*(lat1-lat); >disty=(long1-long)*((longlen+y1len)/2); >distance=round(sqrt(sum(distx**2,disty**2))); >

I am using the macro down below. It calculates the length of the shortest arc through both positions. The main shortcoming is that I assume the earth is a perfect sphere, which it is not. Therefore, there might be better ones.

%MACRO distance(lat1, lon1, lat2, lon2);

%* calculates distance between two locations on earth; %* depends crucially on the accurcy of the calculations!;

%* input: latitude and longitude in radians; %* output: distance in meters, as a data step expression; %* version: 26 June 1996, Willem Dekker;