0
votes

Say I have a latitude of 38.802610 and a longitude of -116.419389 and I want to be able to add a distance to that, 20 miles for example.

So far I have came up with a rough idea on how I would do this

  • Firstly, work out how many miles are in 1° of latitude, say for example it was 30

  • Then, divide one by it:

    • 1 / 30 = 0.033333
  • Add it to my original latitude to get my maximum ° of latitude:
    • 38.802610 + 0.033333 = 38.8355943
  • Subtract it to my original latitude to get my minimum ° of latitude:
    • 38.802610 - 0.033333 = 38.769277

But this is flawed because there seems to be no direct conversion for longitude as from what I've read the calculation varies.

Ultimately, I need to be able to find out the:

  • maximum latitude (my current latitude + given distance e.g 20 miles)
  • minimum latitude (my current latitude - given distance e.g 20 miles)
  • maximum longitude (my current longitude + given distance e.g 20 miles)
  • minimum longitude (my current longitude - given distance e.g 20 miles)

Any help would be greatly appreciated, thank you.

1
Haversine formula should help you with thatGianlucca
I did see that article, but I'm very new to all this so I'm not really sure how to apply it to my situation?John Jones

1 Answers

0
votes

Linear distances (e.g. 20 miles or 32186.88 m) cannot directly be converted to distances in degrees of latitude or longitude, since the Earth is not flat. However, there are two direct conversion you can try to project one point given a linear distance and azimuth to another point.

Method 1 is to assume a spherical Earth, using Movable Type's "destination point given distance and bearing from start point". The underling equations are described on the website. The difference of latitude is the same in North and South directions, and the difference of longitude is the same in East and West directions, so you can do a minimum of two calculations to determine all four min/max and lat/long combinations.

Method 2 is to assumes a spheroid Earth (also called an ellipsoid of revolution), and calculate a direct geodesic with GeographicLib, which has bindings to several programming languages. The difference of latitude is slightly different in North and South directions, but the same in East and West directions, so you can do a minimum of three calculations. Or just assume the difference in North or South directions is approximately the same and just do two calculations. This method has sub-millimetre accuracy.