How to transform a distance from degrees to metres?

瘦欲@ 提交于 2019-12-03 09:03:11

问题


I'm using OpenLayers with an ordinary mercator map and I'm trying to sample a bounding box by finding a grid of points in latlong. The bbox is expressed in latlon, e.g.

48.1388,-15.3616,55.2057,-3.9359

I can define a distance in degrees (e.g. x: 2.5, y: 2.4) and work out the points from there. But I'd like to express this distance in metres (e.g. 50000) in order to relate it to the user mindset (people understand metres, not degrees). How can I convert this distance? I know how to reproject a point, but not a distance.

Thanks for any hints! Mulone


回答1:


Use the haversine formula to get the distance between two points of lat/long. This assumes the earth is a sphere (which is, for most cases, "good enough").

A Javascript implementation of it (shamelessly stolen from here) looks like this:

var R = 6371; // km
var dLat = (lat2-lat1).toRad();
var dLon = (lon2-lon1).toRad(); 
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
        Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) * 
        Math.sin(dLon/2) * Math.sin(dLon/2); 
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
var d = R * c;



回答2:


Without allowing for the slightly non-spherical shape of the earth,

One minute of latitude North to south = 1 Nautical Mile = 6075 feet So One degree = 60 Minutes = 60 * 6075 feet There are 3.28 Feet in a meter so One degree = 60 * 6075 / 3.28 Meters = 111,128 meters

Alternatively, one minute of Latitude = 1,852 Meters So One degree = 60 * 1852 meters = 111,120 meters

I'm not sure which is more accurate...

For One degree of Longitude, do the same thing, but Multiply by the Cosine (Latitude) since the Longitude lines get closer together as you move north.




回答3:


The transformation between degrees and metres varies across the Earth's surface.

Assuming a spherical Earth, degrees latitude = distance * 360 / (2*PI * 6400000)

Note that longitude will vary according to the latitude:

Degrees longitude = distance *360 * / (2*PI* cos(latitude) )

The above is for the Earth's surface, and does not use the Mercator projection. If you wish to work with projected linear distance, then you will need to use the Mercator projection.



来源:https://stackoverflow.com/questions/4102520/how-to-transform-a-distance-from-degrees-to-metres

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!