如何将距离从度转换为米?
我将 OpenLayers 与普通墨卡托地图一起使用,并尝试通过查找经纬度中的点网格来对边界框进行采样。 bbox 以纬度表示,例如
48.1388,-15.3616,55.2057,-3.9359
我可以定义以度为单位的距离(例如 x: 2.5,y: 2.4)并从那里计算出点。 但我想用米来表示这个距离(例如50000),以便将其与用户心态联系起来(人们理解米,而不是度)。 我怎样才能转换这个距离?我知道如何重新投影一个点,但不知道如何重新投影距离。
感谢您的任何提示! 穆隆
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用haversine 公式 获取纬度/经度两点之间的距离。这假设地球是一个球体(在大多数情况下,“足够好”)。
它的 Javascript 实现(从此处无耻地窃取)如下所示:
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:
不考虑地球的轻微非球形形状,
从北到南纬度一分钟 = 1 海里 = 6075 英尺
所以 1 度 = 60 分钟 = 60 * 6075 英尺
一米有 3.28 英尺,所以
1 度 = 60 * 6075 / 3.28 米 = 111,128 米
或者,一分钟纬度 = 1,852 米
所以 1 度 = 60 * 1852 米 = 111,120 米
我不确定哪个更准确...
对于 1 度经度,做同样的事情,但乘以余弦(纬度),因为经度线收敛,(得到当您向北移动时,彼此靠得更近。
注意:如果您使用计算器或计算机,请确保使用设备要求或设置使用的正确纬度单位(度或弧度)。
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 converge, (get closer together), as you move north.
Note: if you're using a calculator or computer, make sure you use the right units for the latitude (degrees or radians) that your device requires or is set to use.
度和米之间的转换在地球表面各不相同。
假设地球是球形的,纬度度 = 距离 * 360 / (2*PI * 6400000)
请注意,经度会根据纬度而变化:
经度 = 距离 *360 * / (2*PI* cos(latitude) )
上面是对于地球表面,并且不使用墨卡托投影。如果您希望使用投影线性距离,则需要使用墨卡托投影。
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.