How do I find the lat/long that is x km north of a given lat/long?

前端 未结 7 1108
花落未央
花落未央 2020-11-30 03:48

I have some C# code that generates google maps. This codes looks at all the Points I need to plot on the map and then works out the Bounds of a rectangle to include those po

7条回答
  •  清歌不尽
    2020-11-30 04:25

    I'm not sure if I'm missing something here, but I think the question could be rephrased as, "I have a lat/lon point, and I want to find the point x meters north and x meters south of that point."

    If that's the question then you don't need to find a new longitude (which makes things simpler), you just need a new latitude. A degree of latitude is roughly 60 nautical miles long anywhere on Earth, and a nautical mile is 1,852 meters. So, for new latitudes x meters north and south:

    north_lat = lat + x / (1852 * 60)
    north_lat = min(north_lat, 90)
    
    south_lat = lat - x / (1852 * 60)
    south_lat = max(south_lat, -90)
    

    This is not completely accurate because the Earth is not a perfect sphere with exactly 60 nautical miles between each degree of latitude. However, the other answers assume that lines of latitude are equidistant, so I'm assuming you don't care about that. If you're interested in how much error that might introduce, there is a nice table on Wikipedia that shows "Surface distance per 1° change in latitude" for different latitudes at this link:

    http://en.wikipedia.org/wiki/Latitude#Degree_length

提交回复
热议问题