Converting Latitude/Longitude (decimal degrees) to Bearing?

  • Permalink
  • submit to reddit
  • Email
  • Follow


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
Reply anderson115 (37) 6/12/2007 8:53:03 PM

See related articles to this posting


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
Reply 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
Reply BD9439 (93) 6/13/2007 9:28:40 PM
comp.soft-sys.sas 130842 articles. 26 followers. Post

2 Replies
641 Views

Similar Articles

[PageSpeed] 32


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Re: Converting Latitude/Longitude (decimal degrees) to Bearing?
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 h...

Re: Converting Latitude/Longitude (decimal degrees) to Bearing? #3 690796
BD9439@ATT.COM replied: > >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. Good code is always appreciated. I don't think it is too long for SAS-L. > 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 It's basic spherical trigono...

Re: Converting Latitude/Longitude (decimal degrees) to Bearing? #3 1563858
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, ch...

Latitude longitude minutes to decimal degrees
I want to convert Latitude and Longitude minutes to decimal degrees. My Lats and Lons are stored in text files, in columns such that the minutes are in the same column as the degrees. No spaces, or commas, or tabs seperate the minutes from degrees. Below is what I have to start with, and below that is what I want to end up with. Here is what I am starting with: %CRUISE CTD CTD_LAT CTD_LONG CTD_DEPTH TEMPERATURE 8705 3 3649 12205.09961 10 13.61400032 8705 4 3649 12210.90039 10 13.43519974 8705 5 3649 12216.90039 10 13.51290035 Here is what I want to end up with: %CRUISE CTD CTD_LAT CTD_LONG C...

Convert from HEX to decimal Latitude and Longitude
I have a binary file with coordinates in Latitude and Longitude how can I convert then to degrees? Byte 180-183 (Latitude) Hex 119c67 integer 18418791 Byte 184-187 (Longitude) Hex 0fbe72 integer 16508674 Decoded Decimal: Latitude 30.697985 Longitude 27.514457 Any help please. Thanx <sazykin@gmail.com> wrote... >I have a binary file with coordinates in Latitude and Longitude > how can I convert then to degrees? First you should understand your data... It's very simple arithmetics. > > Byte 180-183 (Latitude) > He...

Convert from HEX to decimal Latitude and Longitude
I have a binary file with coordinates in Latitude and Longitude how can I convert then to degrees? Byte 180-183 (Latitude) Hex 119c67 integer 18418791 Byte 184-187 (Longitude) Hex 0fbe72 integer 16508674 Decoded Decimal: Latitude 30.697985 Longitude 27.514457 Any help please. Thanx On 14-8-2006 14:38, sazykin@gmail.com wrote: > I have a binary file with coordinates in Latitude and Longitude how can > I convert then to degrees? > > Byte 180-183 (Latitude) > Hex 119c67 integer 18418791 > Byte 184-187 (Longitude) > H...

Code to convert MGRS coordinates to latitude and longitude (degrees,
From: clusardi2k@aol.com Does anyone have code to covert to latitude and longitude coordinates (in degrees, minutes, and seconds) from MGRS coordinates? I don't want code with a license. So, I'm not interested in the code from http://openmap.bbn.com/doc/api/com/bbn/openmap/proj/coords/MGRSPoint.html Basically, do you have a working project that I can look at that shows how to use your code. Thank you, --- BBBS/Li6 v4.10 Dada-1 * Origin: Prism bbs (1:261/38) --- Synchronet 3.16a-Win32 NewsLink 1.98 Time Warp of the Future BBS - telnet://time.synchro.net:24 ...

Code to convert MGRS coordinates to latitude and longitude (degrees, minutes, seconds)
Does anyone have code to covert to latitude and longitude coordinates (in degrees, minutes, and seconds) from MGRS coordinates? I don't want code with a license. So, I'm not interested in the code from http://openmap.bbn.com/doc/api/com/bbn/openmap/proj/coords/MGRSPoint.html Basically, do you have a working project that I can look at that shows how to use your code. Thank you, On Mon, 13 Aug 2012 09:38:12 -0700 (PDT), clusardi2k@aol.com wrote, quoted or indirectly quoted someone who said : > >Basically, do you have a working project that I can look at that sho...

Converting degrees DDD.MM.SS to Degrees in decimal
Is there an easy way on the 49G+ to convert back and forth from degrees, minutes, seconds to degrees in decimal? GC Chips wrote: > Is there an easy way on the 49G+ to convert back and forth from degrees, > minutes, seconds to degrees in decimal? > > GC > > ->HMS HMS-> In article <6cSje.1622$mK.617@newssvr13.news.prodigy.com>, "Chips" <Chips1@reliableins.nospam> wrote: > Is there an easy way on the 49G+ to convert back and forth from degrees, > minutes, seconds to degrees in decimal? > > GC Yes! Think of hours, minute...

Converting Lat/Long from degrees-minutes-second to decimal degrees [telecom]
Here's a great FCC site that converts Latitude and Longitude in Degrees, Minutes, and Seconds to or from Decimal Degrees. http://transition.fcc.gov/mb/audio/bickel/DDDMMSS-decimal.html HTH. Bill In article <E1T3Iqi-0003JI-1V@telecom.xen.prgmr.com>, <bill@horne.VALID-IF-THIS-IS-ELIDED.net> wrote: >Here's a great FCC site that converts Latitude and Longitude in >Degrees, Minutes, and Seconds to or from Decimal Degrees. >http://transition.fcc.gov/mb/audio/bickel/DDDMMSS-decimal.html Of course, with no disrespect to Dale Bickel, it's also trivial to d...

Latitude to decimal degrees.
Hi All, I have a this code to grab the input global latitude reading and change it to a degree decimal reading. .......... code snip........ public void actionPerformed(ActionEvent event) { //calculations below flocdegree = Double.parseDouble(tf1.getText()); flocmin = Double.parseDouble(tf2.getText())/60; flocsec = Double.parseDouble(tf3.getText())/3600; flocdegree = flocdegree + flocmin + flocsec; locdir1= tf4.getText(); System.out.println(locdir1); if (locdir1.equals("S") ) flocdegree = -1* flocdegree; if (locdir1...

Convert Latitude, Longitude To TimeZone
------=_NextPart_000_000B_01CE2E30.3CC0F6B0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi All I'm new to python (4 days J) and was wondering if anyone out there can help me I am trying to get the time zones for latitude and longitude coordinates but am having a few problems The mistakes are probably very basic I have a table in a database with around 600 rows. Each row contains a lat long coordinate for somewhere in the world I want to feed these co-ordinates into a function and then retrieve the time zone....

Geocoding- converting addresses to Latitude and longitudes
I'm trying to javascript for my first time using the Google Maps API program. I was wondering if anybody could explain how to convert an address into latitude and longitude in my javascript. using the getLatLng to convert an address into Glatlng. I don't know what this means AJ, see here for the Google Maps API documentation on the matter: http://www.google.com/apis/maps/documentation/#Geocoding_Examples If that doesn't clarify things I suggest posting a message in the "Google-Maps-API" group. This is a general javascript group and they can better help you there. AJ ...

Converting from decimal degrees to DMS on 49G+
I have searched the newsgroup archives, and the user's manual for the 49G+ but I can't find any explanation for how to convert from degrees, minutes, and seconds to decimal degrees and vice versa. There are plenty of articles about how to do it on the 48G's, but none for the 49G+. Can anyone help me? Thanks in advance, Eric "Eric Dickerson" <dickerson_eric@hotmail.com> wrote in message news:1d98a705.0404141032.6236cff2@posting.google.com... > I have searched the newsgroup archives, and the user's manual for the > 49G+ but I can't find any explana...

Convert to Latitude/Longitude from Eastings/Northings
I have a set of OS (UK) eastings/northing which I need to convert to Latitude/Longitude. Is there any basic calculation that will provide this conversion or even a close approximation? On Sep 17, 5:21=A0pm, Robin9876 <robin9...@hotmail.com> wrote: > I have a set of OS (UK) eastings/northing which I need to convert to > Latitude/Longitude. Is there any basic calculation that will provide > this conversion or even a close approximation? You could try this conveter written for the OS: http://tinyurl.com/27wpc7 It'll convert a text file of lat/long's into X &...

Anyone Converted address to latitude and longitude?
I'm creating an app to find 5 locations that are closest to an address. All locations are in a table with latitude and longitude not addresses. I will need to convert the given address. Thanks James In article <410da401-f2f4-4475-9593-4daee1bc545d@googlegroups.com>, <jmepham@gmail.com> wrote: >I'm creating an app to find 5 locations that are closest to an address. >All locations are in a table with latitude and longitude not addresses. >I will need to convert the given address. > >Thanks > >James I am aware of a public domain zipco...

Programing Language: latitude-longitude-decimalize
fun programing exercise. Write a function =E2=80=9Clatitude-longitude- decimalize=E2=80=9D. It should take a string like this: =E3=80=8C"37=C2=B026=E2=80=B236.42=E2=80= =B3N 06=C2=B015=E2=80=B214.28=E2=80=B3W"=E3=80=8D. The return value should be a pair of numbers, like this: =E3=80=8C[37.44345 -6.25396]=E3=80=8D. Feel free to use perl, python, ruby, lisp, etc. I'll post a emacs lisp solution in a couple of days. Xah Last time I did this was using AS3. The format I used was DMS: GPSLongitude: 122,42,47.79 GPSLongitudeRef: W GPSLatitude: 45,30,30.390001198897014 GPSLatitudeR...

Converting northings and eastings to latitude and longitude
Hi guys, I wonder if any you guys could help me. Is there a function available that is able to convert northings and eastings for utm zone 30U into decimal latitude and longitude values. Any help would be very much apprecciated. On Jan 20, 11:18=A0am, "Ian " <ikirb...@yahoo.com> wrote: > Hi guys, > > I wonder if any you guys could help me. Is there a function available tha= t is able to convert northings and eastings for utm zone 30U into decimal l= atitude and longitude values. Any help would be very much apprecciated. I guess it depends where you live. ...

problems converting to Cylindrical (longitude-latitude)
I'm having trouble converting images to Cylindrical (longitude- latitude) coordinates. My input data are in Albers Equal-Area and cover the western US. When I convert to lon-lat coordinates I get output images and bounds that are clearly wrong. I must be misusing MAP_PROJ_INIT and MAP_PROJ_IMAGE, but am not sure how. Any suggestions would be welcome. Here's what I have tried: ; Data are in Albers Equal-Area; output is to be Cylindrical. ; Albers projection parameters spar1 = 20 spar2 = 60 clon = -103 clat = 45 ; Corners of images (in meters) as stated in metadata. xmin = -1567000.0 ...

geographic latitude longitude degree to menit
Dear matlabers, I have many data in geographical coordinate for example 08&#65439;46.645'S. I want to change this into -8.72981667 and 111&#65439;08.010'E into 108.9944333. Please help me. Thank you ...

converting latitude and longitude into UTM coordinates
hi can anybody help me to convert latitude and longitude into UTM coordinates maybe someone have a program &nbsp; thanks do you searched the internet for that? &nbsp; My quick search return this link: &nbsp; <a href="http://www.uwgb.edu/dutchs/usefuldata/utmformulas.htm" target="_blank">http://www.uwgb.edu/dutchs/usefuldata/utmformulas.htm</a> &nbsp; In this, you can find also a spreadsheet that may help more. &nbsp; See if it's good for you ...

Convert MGRS to Latitude/Longitude and vice versa
Hello, I am needing to batch convert many Military Grid Reference System (MGRS) coordinates to Latitude/Longitude coordinates, and vice versa. Matlab is a requirement, as it will be embedded in a much larger Matlab application. The machines which these scripts will be run on will not have internet access, so the solution cannot involve the Web. The functionality I want is essentially what the following webpage provides: http://www.arsitech.com/mapping/mgrs/ Let's assume the WGS84 datum is used. Is there an existing Matlab function that can do this? If not, is anyone familiar with ...

Calculate new Latitude / Longitude from Bearing and Distance
Greetings, does anyone have a calculation that calculates the new latitude and longitude based on a starting point, bearing and distance? I would greatly appreciate any help people might have. Many Thanks, Aaron Aaron, I think the formulae shown on the following page will help: http://www.movable-type.co.uk/scripts/latlong.html Art -------- On Wed, 21 Jan 2009 16:55:12 -0800, anderson115@GMAIL.COM wrote: >Greetings, does anyone have a calculation that calculates the new >latitude and longitude based on a starting point, bearing and >distance? > >I would greatly appreciate...

How to convert latitude/longitude to x,y coordinates
Hello, I am using arcgis 8.3 and need some step by step instructions on how to convert latitude/longitude to x,y coordinates. thanks they already are x and y coordinates steve wrote: > Hello, > I am using arcgis 8.3 and need some step by step instructions on how to > convert latitude/longitude to x,y coordinates. > thanks > > "steve" <noreal@address.com> wrote in news:_ygOb.14668$zj7.618@newsread1.news.pas.earthlink.net: It depends on what coordinate system you want to convert to. I use a program from US Corps of Engin...