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 133512 articles. 0 followers. Post Follow

2 Replies
1298 Views

Similar Articles

[PageSpeed] 32
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 (1912)
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:
Similar Artilces:

regexp is blind to decimal point (.)?!?!
I am trying to use regexp to determine whether or not a string has a period (.) in it. a='1.232' regexp(a,'.') for some reason this returns 1 2 3 4 5 works for all the other numbers and characters for instance regexp(a,'2') returns 3 5 (positions in a where there are twos) Any ideas? Thanks On Aug 8, 4:48 pm, "matt v" <matthew...@gmail.com> wrote: > I am trying to use regexp to determine whether or not a > string has a period (.) in it. > > a='1.232' > regexp(a,'.') > for some reason this returns > 1 2 3 4 5 >...

How to convert xls2pdf How to convert xls2txt
a. Where would there be a converter by email for xls2pdf ..xls to .pdf b. or a coverter by email for xls2txt ..xls to text c. where you send the .xls attachment by email and get the conversion by email d. or even preferable you can send the .xls attachment by email and read it at a web link. Hi Don Don Saklad wrote: > a. > Where would there be a converter by email for > xls2pdf > .xls to .pdf > > b. > or a coverter by email for > xls2txt > .xls to text There are others a lot more prone to answer this one, but: XLS, as I understand it, really IS text, so mayb...

Convert xml to xls?
Hi all, does anyone know about an open-source tool or method that can convert a certain xml file to a spreadsheet (e.g. xls)? Can one import xml data in the OpenOffice program Calc? The problem is that the original xml file can be very long and the digit precision of some data fields is strictly required. Thanks a lot! Jie On Oct 21, 3:16=A0pm, Jie <Jie....@gmail.com> wrote: > Hi all, > > does anyone know about an open-source tool or method that can convert > a certain xml file to a spreadsheet (e.g. xls)? Can one import xml > data in the OpenOffice program Calc? The p...

convert m-file to simulink
How can I convert m-file which consist of ANN(Artificial Neural Network) to simulink block for simulation? Please do reply as soon as possible. Hi, you can use your m-file in Simulink with the user-defined functions. There is a Block matlab-fcn there. Inputs can be taken from source blocks, outputs can be visualized in sinks, as e.g. scopes. regards badariah mahbob wrote: > > > How can I convert m-file which consist of ANN(Artificial Neural > Network) to simulink block for simulation? > > Please do reply as soon as possible. "badariah mahbob" <bardzcomel@...

I need a good sas dataset to html converter
I need a good sas dataset to html converter. Does anyone have any links to code that can do this? ...

US-CA-San Diego: Staff Engineer, Environmental Eng exp, CAD skills, BA degree; P (45319757607)
US-CA-San Diego: Staff Engineer, Environmental Eng exp, CAD skills, BA degree; P (45319757607) ============================================================================================== Position: Staff Engineer Reference: SMC01426 Location: San Diego CA Duration: Perm Skills: Bachelors degree in Environmental Engineering (or Civil or Chemical with Environmental Emphasis). 2-4 years experience in environmental engineering. Strong communication and computer skills. CAD skills desirable but not necessar...

US-CA-Chino/Temecula: Sr. Project Eng., Const. project exp., RCE/GE, MA Degree; (45303857637)
US-CA-Chino/Temecula: Sr. Project Eng., Const. project exp., RCE/GE, MA Degree; (45303857637) ============================================================================================= Position: Sr. Project Eng. Reference: SMC01420 Location: Chino/Temecula CA Duration: C-P Skills: Masters degree in Civil Engineering with Geotechnical specialty 10+ yrs of exp in managing public works, commercial, residential land development and construction projects California Professional registration (RCE / GE) ...

Convert Current Time to Dec
Sorry, This should be simple, but brain is hurting... How do I convert a Current Time to a Decimal 6,0 (HMS)? There must be a cleaner way then this: Insert into Table Values Dec( Substr(Char(CURRENT TIMESTAMP),12,2) || Substr(Char(CURRENT TIMESTAMP),15,2) || Substr(Char(CURRENT TIMESTAMP),18,2) ,6,0) TIA, Chris Take a peak at HOUR(), MINUTE(), and SECOND(). DEC() can also be used directly on the timestamp. integer(dec(current timestamp) - dec(current date) * 1000000) or round(dec(current timestamp) - dec(current date) * 1000000, 0) Simply use ...

converting cd server into file server
I have a procom CDT-21 21 bay scsi cd tower. I would like to change it into a file server by removing the scsi cd drives an replacing them with scsi hard drives. can this be done? I already have 14 scsi hard drives laying around and also have server 2000 os to put on it. any answers would help. thanks, Dweb ...

pie or bar chart on latitude longitude location
hello, I need help to plot my data for variables (v1, v2, and v3) as pie chart (using all three variables) or as a bar chart but location wise (with lat/lon location). How can I achieve this? myData = [Loc lat lon v1 v2 v3 A 39.7204886 75.83190009 5.504549943 5.571758552 3.59946654 B 39.71372137 75.83786935 3.745411775 6.979060509 4.687800172]; Simply, for location 'A', I should be having a pie or bar chart and then for location 'B' again the same thing. Any ...

VBA for batch convert e00
Any one had made a vba program which using for convert e00 to shp? because I have a lot of e00 files it need to convert to shp and then open by arcmap! Eric Hi Eric, > Any one had made a vba program which using for convert e00 to shp? because I > have a lot of e00 files it need to convert to shp and then open by arcmap! If you don't mind using a 3rd party product, our FME can do this in a number of ways. You could just use our "batch translate" option and a couple of clicks later you'll have everything in shape files (or even personal geodatabase...

[Info-Ingres] views and E_US100F String cannot be converted to numeric
--_000_57765A44B573A747BAEC13DBB1E209AD049F66BEEXCH1ctsuoxacuk_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-WatchGuard-AntiVirus: part scanned. clean action=allow Hi All, I have a distributed database which has a native view (named all_box_store)= which is a select with many union all's of several registered tables. If I run the query... select * from c_slot_allocation a where a.box_cid not in ( select s.box_cid from all_box_store s where a.project_cid =3D s.project_cid and a.rack_cid =3D s.rack_cid and a.slot_p...

converting HH:MM to a decimal
I have 3 pairs of time in/out (24 our clock) that I need to calculate the decimal equivalent of the total time worked for that day. example: time in/out 08:00 10:00, 10:15 12:45, 13:45 16:50 if I use a simple select of time_out �time_ in I get 2:00, 2:30, 3:10 respectfully, or 7:35 total hours. That is 7.58 in decimal. Now how do I change the total hours of 7:35 to a decimal of 7.58 in a single SQL statement? Or will I have to write a proc that does this? ...

Fast, precision driven, cubic to quadratic piecewise degree reduction algos (2)
Q1: I'm not a scholar nor I have to deal with graphics other than in an amateur way, but please tell me what you think: http://www.caffeineowl.com/graphics/2d/vectorial/cubic2quad01.html Q2: are they new or did I reinvented the wheel? Many thanks, Adrian On 4 Oct 2006 acolomitchi@gmail.com wrote: > but please tell me what you think: > http://www.caffeineowl.com/graphics/2d/vectorial/cubic2quad01.html | background="http://www.caffeineowl.com/images/general/bkg.gif" | .normal { color: #DDF0FF } Who's going to read this? I won't! acolomitchi@gmail.com wrote: ...

convert list of strings to set of regexes; convert list of strings to trie
Hello, I need a function that converts a list into a set of regexes. Like so: string_list = ["blaa", "blab", "raaa", "rabb"] print string_list2regexes(string_list) This should return something like: ["bla(a|b)", "ra(aa|bb)"] I am aware of the fact that converting the list to a *trie* would almost do the job. But I couldn't find anything about Python modules that produce tries. Are there any modules that I could use? Or do I have to implement it myself? Klaus [Klaus Neuner] > I need a function that converts a li...

"cannot convert from the charset" error message
wx 2.5.5, Gtk2, unicode, static lib, suse 9.3 when I run my application I get the a dialog box with the following message : "cannot convert from the charset '@LOCALE, UTF-8, ISO-8859-15, CP-1252!" Except this dialog box my program seems to work fine looking through the wx source code I seem to find this error inside *wxCSConv::DoCreate() function (file common/strconv.cpp) anyone experienced this error message before ? any quick fixes on linux besides turning off the logging with wxNullLog ? Any idea why exactly do I get the message ? Thanks, Andrei On ...

The problem with the strings Convert each other
Hello all, &nbsp; &nbsp; Could you help me to&nbsp;solve the following problem using LV7.1? Thank in advance. &nbsp; &nbsp; How can I convert&nbsp;a string of "hexadecimal value"&nbsp;with Normal display style to&nbsp;other string of " the same hexadecimal value"&nbsp;with&nbsp;Hex display style? &nbsp; Best regards, Evan_Lv&nbsp;&nbsp; Here's a more compact alternative. Same result and same precautions. (It acts a little bit differently if you string has e.g. spaces between hex paris.) <img src="http://forums...

converting W*dows like pathnames to file:///
Hi everybody, I want to convert W*dows like pathnames to browser compatible links usind sed like "C:\Documents and Settings\whatever" to "file:///C:/Documents%20and%20Settings/whatever" The second one could be used in W*dows and Linux as well cause Linux allowing links to be named with an ":" in it (at least my Linux [Debian] does) , so /C:/ could be a link to /mnt/hda1 and so on. Unfortunately I cannot code that little bit in sed. :-( Problems: "\" and "/" both have special meanings Converting " " to "%20" Converting Ge...

Lotus 123
Using Lotus (release 9.6 for Windows) I have some dates entered as a fraction (11/1993) and can display them as a number (0.0055) or as a fraction (11/1993). I would like to convert the fraction to text "11/1993" and then split it into the month and year. I know how to split the text, but can't find a way to convert the original entry to text. Any ideas? TIA Arthur "Arthur Hass" wrote... >Using Lotus (release 9.6 for Windows) I have some dates entered as a >fraction (11/1993) and can display them as a number (0.0055) or as a >fraction (1...

how to convert GO TO (Fortran) to Matlab
Hi all, Again, I need your share if you have experience in converting Fortran to Matlab. I have Fortran code working with NCL graphic library. However, I am not successful to run this fortran code in my windows PC (under cygwin). It works perfectly in LINUX, but I want to work only in one PC (windows). Therefore, I plan to convert this fortran to Matlab code, but I got problem to convert GO TO in Fortran to Matlab. For example: DO 250 IX=1,NX-1 X1=XMIN+(IX-1)*DX X4=X1+DX X2=X1 X3=X4 C IF(X1.LT.PX1.OR.X4.GT.PX2)GO TO 250 R1=DAT(IX,IY+1) ...

Question about converting data
hi everyone, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i am working on my senior project. i have previously post some of my question. however, it seems that after a while, no one will reply my post anymore. Therefore, i decided to make a new post. i am using labview 8.2 and trying converting the data from the sensor.&nbsp; Once the sensor is powering on, it keeps sending its measuring value to the computer through the srial port. The use&nbsp; hi and lo bytes represent a value, and I have to read pull out the last 7 bit from hi and low bytes and put them together (so we have ...

Converting movie to image
I want to convert a video file to image, the video file is in 3.GP to image file of Jpg. anyone with useful suggestions and code on how to do this ...

converting data types
Hello All, I am looking for a best way of modifying the column data types. I use the Oracle 9.i For example I have the table: CREATE TABLE testtable ( column1 Float(126) NOT NULL CONSTRAINT TESTTABLE_COLUMN1_Primary PRIMARY KEY, column2 NUMBER(15) NOT NULL); I have the column1 with type 'DOUBLE PRECISION' [Float(126)] and I want to perform it's conversion to any other type (for ex. to VARCHAR2 type), and this column is not empty. If I will convert it just by ALTER TABLE testtable MODIFY(column1 VARCHAR2(24)) I will receive t...

convert a macro variable?
If I have mac var aaa %let aaa = 510-555-1212 ; and I hope to get a new mac var bbb = 510.555.1212 Is there a macro function to convert, from - to . Thanks, Jerry 11 %let aaa = 510-555-1212 ; 12 13 %let b=%sysfunc(translate(&aaa,'.','-')); 14 15 %put &b; 510.555.1212 -----Original Message----- From: jerry chiu [mailto:chiuj2@YAHOO.COM] Sent: Wednesday, October 15, 2003 4:13 PM To: SAS-L@LISTSERV.UGA.EDU Subject: convert a macro variable? If I have mac var aaa %let aaa = 510-555-1212 ; and I hope to get a new mac var bbb = 510.555.1212 Is there a ...

Convert .dbf files to mysql files
Hi everybody I have an application that was developed in Clipper. 70 dbf files and aroud 100 ntx , I plan to move the data to Access and Mysql *.frm *.MYD and *.MYI, But I don't know how to convert the .dbf files and .ntx. files ? Thanks you help..... William, Have a look at the thread from deltatrend started on the 20/8/03..... -- Rob Grattan R&D Software Pty. Ltd. ...