3

I'm looking for a formula that takes a long/lat coordinate and a degree heading, (e.g. "I'm standing in San Francisco and I'm facing 45º from north"), and which can draw a line across a map projecting your path along a globe from that point, along that heading, and back around to you.

So, for example...

  • If you were standing at the equator facing due west, it would just be a horizontal line along the equator.
  • If you were facing due north, it would be a vertical line from your position, and another vertical line at the longitude exactly halfway around the world.
  • If you are standing at a random point and facing a random heading, it would create one of those "sin-wave" paths along the map, like we often see on maps of space stations or shuttles, starting and ending at your current location.

Does a formula like that exist? It seems like it would have to, since it would be one of the most basic formulas for calculating orbital paths and such. But I haven't been able to find anything like it...

  • 1
    Here's a post that should be pretty helpful: stackoverflow.com/questions/10223898/… The OP states they are wanting to draw a line of some distance from a starting point in some direction. Making the length of that line "long" enough will give you pretty good representation of that "sin-wave". There is a link to another post that has a python script with much of the necessary math. – evv_gis Oct 15 '14 at 17:45
  • Also similar: gis.stackexchange.com/questions/81124/… though it would take a good long time to work back to the same place (the Earth is an oblate spheroid, not a sphere). – Vince Oct 15 '14 at 17:50
1

I think the formula you are looking for is the haversine formula.

See the Destination point given distance and bearing from start point section.

Here's an R implementation to add to those given on the site:

# Q: From London, what is 500 kilometres away in the heading of 110 degrees

# London coordinates
earthR <- 6371 # km
olat <- 51.5073509 / 180 * pi
olng <- -0.1277583 / 180 * pi
distance <- 5000 # km
compass_heading <- 110 / 180 * pi

# haversine equation
dlat <- asin(sin(olat) * cos(distance/earthR) + cos(olat) * sin(distance/earthR) * cos(compass_heading))
dlng <- olng + atan2(sin(compass_heading) * sin(distance/earthR) * cos(olat), cos(distance/earthR) - sin(olat) * sin(dlat))

# convert to decimal degrees
dlat <- dlat * 180 / pi
dlng <- dlng * 180 / pi

# A: Luxembourg.

I'm not sure how accurate it is. I will compare it with other methods and see ...

0

What you are looking for is to calculate points along a path starting at a specific lat/lon and bearing. You will want to pick an distance increment (e.g., 100 miles) to incremently plot points following the bearing across the globe.

This stackoverflow answer gives such a formula using the Great Circle method for approximately the spherical of the globe:

https://stackoverflow.com/questions/7222382/get-lat-long-given-current-point-distance-and-bearing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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