Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am wanting to find a latitude and longitude point given a bearing, a distance, and a starting latitude and longitude.

This appears to be the opposite of this question (Distance between lat/long points).

I have already looked into the haversine formula and think it's approximation of the world is probably close enough.

I am assuming that I need to solve the haversine formula for my unknown lat/long, is this correct? Are there any good websites that talk about this sort of thing? It seems like it would be common, but my googling has only turned up questions similar to the one above.

What I am really looking for is just a formula for this. I'd like to give it a starting lat/lng, a bearing, and a distance (miles or kilometers) and I would like to get out of it a lat/lng pair that represent where one would have ended up had they traveled along that route.

share|improve this question
    
Are you looking for a tool that does this (like Esri's pe.dll) or a formula? –  Kirk Kuykendall Feb 4 '11 at 19:06
    
Sorry I wasn't specific... I am looking for a formula. I'll update my question to be more specific. –  Jason Whitehorn Feb 4 '11 at 19:08
    
Closely related: gis.stackexchange.com/questions/2951/…. –  whuber Jul 21 '12 at 17:07
add comment

5 Answers

up vote 8 down vote accepted

I'd be curious how results from this formula compare with Esri's pe.dll.

(citation).

A point {lat,lon} is a distance d out on the tc radial from point 1 if:

 lat=asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc))
 IF (cos(lat)=0)
    lon=lon1      // endpoint a pole
 ELSE
    lon=mod(lon1-asin(sin(tc)*sin(d)/cos(lat))+pi,2*pi)-pi
 ENDIF

This algorithm is limited to distances such that dlon < pi/2, i.e those that extend around less than one quarter of the circumference of the earth in longitude. A completely general, but more complicated algorithm is necessary if greater distances are allowed:

 lat =asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc))
 dlon=atan2(sin(tc)*sin(d)*cos(lat1),cos(d)-sin(lat1)*sin(lat))
 lon=mod( lon1-dlon +pi,2*pi )-pi

Here's an html page for testing.

share|improve this answer
    
Thank you for the quick reply. Let me digest some of this information, and I will get back with you. On the surface, though, this looks spot on. –  Jason Whitehorn Feb 4 '11 at 20:21
    
I tried the direct case using pe.dll (actually libpe.so on solaris) after retrieving the distance and the forward azimuth from the html page for 32N,117W to 40N,82W. Using 32N,117W,d=3255.056515890041,azi=64.24498012065699, I got 40N,82W (actually 82.00000000064). –  mkennedy Feb 4 '11 at 22:17
1  
Awesome! Thank you very much for the link to the Aviation Formulary article by Ed Williams, I had not seen this before but it has thus far proven to be a great read. Just a note for anyone looking at this in the future, the inputs and outputs of this formula are ALL in radians, even the distance. –  Jason Whitehorn Feb 5 '11 at 6:09
add comment

Bunch of worked out math samples are here Calculate distance, bearing and more between Latitude/Longitude points which includes the solution to "Destination point given distance and bearing from start point".

share|improve this answer
    
Thanks heaps BicycleDude, you saved my day :) –  Aref Jan 25 '12 at 2:21
add comment

If you were in a plane, then the point that is r meters away at a bearing of a degrees east of north is displaced by r * cos(a) in the north direction and r * sin(a) in the east direction. (These statements more or less define the sine and cosine.)

Although you are not in a plane--you're working on the surface of a curved ellipsoid that models the Earth's surface--any distance less than a few hundred kilometers covers such a small part of the surface that for most practical purposes it can be considered flat. The only remaining complication is that one degree of longitude does not cover the same distance as a degree of latitude. In a spherical Earth model, one degree of longitude is only cos(latitude) as long as a degree of latitude. (In an ellipsoidal model, this is still an excellent approximation, good to about 2.5 significant figures.)

Finally, one degree of latitude is approximately 10^7 / 90 = 111,111 meters. We now have all the information needed to convert meters to degrees:

The northwards displacement is r * cos(a) / 111111 degrees;

The eastwards displacement is r * sin(a) / cos(latitude) / 111111 degrees.

For example, at a latitude of -0.31399 degrees and a bearing of a = 30 degrees east of north, we can compute

cos(a) = cos(30 degrees) = cos(pi/6 radians) = Sqrt(3)/2 = 0.866025.
sin(a) = sin(30 degrees) = sin(pi/6 radians) = 1/2 = 0.5.
cos(latitude) = cos(-0.31399 degrees) = cos(-0.00548016 radian) = 0.999984984.
r = 100 meters.
east displacement = 100 * 0.5 / 0.999984984 / 111111 = 0.000450007 degree.
north displacement = 100 * 0.866025 / 111111 = 0.000779423 degree.

Whence, starting at (-78.4437, -0.31399), the new location is at (-78.4437 + 0.00045, -0.31399 + 0.0007794) = (-78.4432, -0.313211).

A more accurate answer, in the modern ITRF00 reference system, is (-78.4433, -0.313207): this is 0.43 meters away from the approximate answer, indicating the approximation errs by 0.43% in this case. To achieve higher accuracy you must use either ellipsoidal distance formulas (which are far more complicated) or a high-fidelity conformal projection with zero divergence (so that the bearing is correct).

share|improve this answer
add comment

If you're interested in better accuracy, there's Vincenty. (Link is to the 'direct' form, which is exactly what you're after).

There are quite a few existing implementations, if you're after code.

Also, a question: You're not assuming the traveller maintains the same bearing for the entire trip, are you? If so, then these methods aren't answering the right question. (You'd be better off projecting to mercator, drawing a straight line, then un-projecting the result.)

share|improve this answer
    
Very good question, despite the wording in my question that may have indicated that I was calculating a destination for a traveler, I am not. Good point though. This was mainly so that I could calculate a bounding area (on a small order, say 50 miles)... I hope that makes sense. –  Jason Whitehorn Feb 6 '11 at 3:45
    
gis.stackexchange.com/questions/3264/… had the same question (constructing bounding areas from a point & distance) –  Dan S. Feb 7 '11 at 19:46
add comment

/*
I use the approach described below in determining the next coordinate given the bearing and distance from previous coordinate. I have problem on accuracy with other approach I read from the internet. I use this in determining the area of land, which is a polygon, and plot that polygon in google earth. A land Title has bearings and distances written in this manner: "NorthOrSouth x degrees y minutes EastOrWest, z meters to point n;". So, starting from the given coordinates of the reference point, I first compute the distance per one degree latitude and one degree longitude using haversine formula because this varies depending on location. Then I determine the next coordinate from the trigonometry sine and cosine formula. Below is the javascript:
*/
var mapCenter = new google.maps.LatLng(referencePointLatitude, referencePointLongitude); //the ref point lat and lon must be given, usually a land mark (BLLM)
var latDiv = latDiv(mapCenter); //distance per one degree latitude in this location
var lngDiv = lngDiv(mapCenter); //distance per one degree longitude in this location
var LatLng2 = NextCoord(PrevCoord,NorthOrSouth,x,y,EastOrWest,z); //next coordinate given the bearing and distance from previous coordinate
var Lat2 = LatLng2.lat(); //next coord latitude in degrees
var Lng2 = LatLng2.lng(); //next coord longitude in degrees
var polygon=[p1,p2,...,pn-1,pn,p1]; //p1,p2,etc. are the coordinates of points of the polygon, i.e. the land Title. Be sure to close the polygon to the point of beginning p1
var area = Area(polygon); //area of the polygon in sq.m.
function NextCoord(PrevCoord,NorthOrSouth,x,y,EastOrWest,z) {
    var angle = ( x + ( y / 60 ) ) * Math.PI / 180;
    var a = 1;
    var b = 1;
    if (NorthOrSouth == 'South') { a = -1; }
    if (EastOrWest == 'West') { b = -1; }
    var nextLat = PrevCoord.lat() + ( a * z * Math.cos(angle) / latDiv );
    var nextLng = PrevCoord.lng() + ( b * z * Math.sin(angle) / lngDiv );
    var nextCoord = new google.maps.LatLng(nextLat, nextLng);
    return nextCoord;
}
function latDiv(mapCenter) {
    var p1 = new google.maps.LatLng(mapCenter.lat()-0.5, mapCenter.lng());
    var p2 = new google.maps.LatLng(mapCenter.lat()+0.5, mapCenter.lng());
    return dist(p1,p2);
}
function lngDiv(mapCenter) {
    var p3 = new google.maps.LatLng(mapCenter.lat(), mapCenter.lng()-0.5);
    var p4 = new google.maps.LatLng(mapCenter.lat(), mapCenter.lng()+0.5);
    return dist(p3,p4);
}
function dist(pt1, pt2) {
    var dLat = ( pt2.lat() - pt1.lat() ) * Math.PI / 180;
    var dLng = ( pt2.lng() - pt1.lng() ) * Math.PI / 180;
    var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
          Math.cos(rad(pt1.lat())) * Math.cos(rad(pt2.lat())) *
          Math.sin(dLng/2) * Math.sin(dLng/2);
    var R = 6372800; //earth's radius
    var distance = R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
    return distance;
}
function Area(polygon) {
    var xPts=[];
    for (i=1; i<polygon.length; i++) { xPts[i-1] = ( polygon[i].lat() - polygon[0].lat() ) * latDiv; }
    var yPts=[];
    for (i=1; i<polygon.length; i++) { yPts[i-1] = ( polygon[i].lng() - polygon[0].lng() ) * lngDiv; }
    var area = 0;
    j = polygon.length-2;
    for (i=0; i<polygon.length-1; i++) {
       area = area + ( xPts[j] + xPts[i] ) * ( yPts[j] - yPts[i] );
       j = i;
    }
    area = Math.abs(area/2);
    return area;
}

share|improve this answer
1  
The Cartesian formula for polygon area you attempt to apply here is not applicable to distances and angles computed on a curved surface (such as a spheroid). This formula makes an additional error by using latitude and longitude as if they were Cartesian coordinates. The only circumstances under which its use could be considered would be exactly those (for very small polygons) where the haversine formula is unnecessary anyway. Overall it appears this code works much too hard for no gain. –  whuber Jun 28 at 14:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.