f



Converting Latitude/Longitude (decimal degrees) to Bearing?

Does someone have a formula to convert the lat and lon from two
locations (A and B) to bearings (location B relative to location A)?

0
6/12/2007 8:53:03 PM
comp.soft-sys.sas 142828 articles. 3 followers. Post Follow

2 Replies
2477 Views

Similar Articles

[PageSpeed] 27

Hi,

Here are some posts to get you started:

http://listserv.uga.edu/cgi-bin/wa?A2=ind0605D&L=sas-l&P=R6483

http://listserv.uga.edu/cgi-bin/wa?A2=ind0511C&L=sas-l&P=R32434




Mark Terjeson
Senior Programmer Analyst, IM&R
Russell Investments
253-439-2367


Russell
Global Leaders in Multi-Manager Investing





-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
anderson115@GMAIL.COM
Sent: Tuesday, June 12, 2007 1:53 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Converting Latitude/Longitude (decimal degrees) to Bearing?

Does someone have a formula to convert the lat and lon from two
locations (A and B) to bearings (location B relative to location A)?
0
mterjeson (1913)
6/12/2007 9:01:05 PM
Hi

Here's a little SAS example to calculate both the bearing and the
distance between two points.  It's a bit long-winded for illustration
purposes.  I got a lot of help from this web site:

http://www.movable-type.co.uk/scripts/latlong.html

There are two different distance calculation techniques used and either
works for me.  I don't claim to understand how any of this works; I just
have this in my SAS toolbox.  There are many online discussions out
there if you're interested.  It seems to depend on the degree of
accuracy you need.  And if you need distance in kilometers, change the
earth radius constant to kilometers (see the comment).

Hope this helps; the code follows.

Bob

data SAMPLE_TABLE1(keep=deg_lat1 deg_lon1 deg_lat2 deg_lon2 distance1
distance2
                     deg_bearing bearing_txt);
   if _n_ = 1 then do;
      /* Define Pi and the Radius of the Earth as constants */
      Pi = constant('pi'); /* Use the SAS function to improve precision
*/
*      REarth = 6367;       /* Kilometers */
       REarth = 3956.2704;  /* Miles */
      end;
   retain Pi REarth;

   /* First point */
   deg_lon1 = -81.2238;
   deg_lat1 =  35.25927;

   /* Second point */
   deg_lon2 = -81.1492;
   deg_lat2 =  35.22143;

   /* First convert degrees to radians */
   rad_lon1 = deg_lon1 * pi / 180;
   rad_lat1 = deg_lat1 * pi / 180;
   rad_lon2 = deg_lon2 * pi / 180;
   rad_lat2 = deg_lat2 * pi / 180;

   /* Law of Cosines for Spherical Trigonometry (uses radius) */
   distance1 = REarth * arcos( ( cos(rad_lat1) * cos(rad_lat2) *
cos(rad_lon1-rad_lon2) )
                             + ( sin(rad_lat1) * sin(rad_lat2) ) );
   /* Haversine Formula (uses diameter) */
   A = sin( (rad_lat2 - rad_lat1)/2.0 )**2
    + ( cos(rad_lat1) * cos(rad_lat2) * sin((rad_lon2 -
rad_lon1)/2.0)**2 );
   distance2 = (REarth * 2) * atan2(sqrt(A),sqrt(1-A));

   /* Calculate bearing */
   rad_Bearing = mod(atan2(sin(rad_lon1-rad_lon2)*cos(rad_lat2),

cos(rad_lat1)*sin(rad_lat2)-sin(rad_lat1)*cos(rad_lat2)*cos(rad_lon1-rad
_lon2)), 2*Pi);

   /* Convert bearing to degrees and create display variable as
degrees-minutes-seconds */
   deg_Bearing = rad_Bearing * 180 / Pi;

   Degrees = Int(abs(deg_Bearing));
   Minutes = (abs(deg_Bearing) - Degrees) * 60;
   Seconds = round((Minutes - Int(Minutes)) * 60);
   Bearing_txt = put(degrees,3.) || 'B0'x || put(minutes,2.) || "'" ||
put(seconds,2.) || '"';
run;


-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
anderson115@GMAIL.COM
Sent: Tuesday, June 12, 2007 1:53 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Converting Latitude/Longitude (decimal degrees) to Bearing?

Does someone have a formula to convert the lat and lon from two
locations (A and B) to bearings (location B relative to location A)?
0
BD9439 (92)
6/13/2007 9:28:40 PM
Reply:

Web resources about - Converting Latitude/Longitude (decimal degrees) to Bearing? - comp.soft-sys.sas

PastBook’s Filepicker.io Integration Eases Process Of Converting Facebook Content To Books
PastBook , one of several companies that allow Facebook users to publish their content on the social network in actual books , announced the ...

Facebook No Longer Converting Groups Into Pages
Back when Facebook first launched Facebook Pages, many businesses and brands who had built up substantial audiences in their Facebook Groups ...

Zwartz Laminating-Converting B.V. on the App Store on iTunes
Get Zwartz Laminating-Converting B.V. on the App Store. See screenshots and ratings, and read customer reviews.


"Occupier" Thanked Former Soviet Citizen for "Converting" Him to Capitalism, Pro-Israel, Pro-USA - YouTube ...
May Day Demonstration on Union Square in New York City Zionism & Birth of Modern Israel in 1948: Former Soviet Citizen Pays Tribute to Ben-Gurion ...

Converting dry air to water: solution to Broken Hill's water crisis gains support
A one-man crusade by a Broken Hill resident to solve the historic town's water crisis by introducing air to water converters is gaining support. ...

Click go fears of converting print files
Is there a way to convert a print queue item to a .RTF or .PDF file? I like to save or email them. - The Sydney Morning Herald

Sudanese woman ordered to hang under sharia law for converting to Christianity gives birth
Khartoum, Sudan: A Christian Sudanese woman sentenced to hang for apostasy has given birth in jail, a Western diplomat said on Tuesday.

Imams warn against radicalism to Aboriginal inmates converting to Islam
The prison system has enlisted the help of ASIO to crack down on radicalisation behind bars amid revelations that Aboriginals are converting ...

Converting the world's companies one by one - The Science Show - ABC Radio National (Australian Broadcasting ...
Image: Trucks carrying logs make their way up a road in Jambi, Indonesia. A vast area of the Sumatran forest, and orangutan habitat, is being ...

Resources last updated: 2/26/2016 8:40:45 PM