从纬度,经度转换为x,y [英] Convert from latitude, longitude to x, y

查看:133
本文介绍了从纬度,经度转换为x,y的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将GPS位置(纬度,经度)转换为x,y坐标. 我找到了许多与此主题相关的链接并加以应用,但是并没有给我正确的答案!

I want to convert GPS location (latitude, longitude) into x,y coordinates. I found many links about this topic and applied it, but it doesn't give me the correct answer!

我正在按照以下步骤测试答案: (1)首先,我占据两个位置并使用地图计算它们之间的距离. (2)然后将两个位置转换为x,y坐标. (3)然后再次计算x,y坐标中两点之间的距离 并查看它是否在point(1)上给我相同的结果.

I am following these steps to test the answer: (1) firstly, i take two positions and calculate the distance between them using maps. (2) then convert the two positions into x,y coordinates. (3) then again calculate distance between the two points in the x,y coordinates and see if it give me the same result in point(1) or not.

我找到了以下解决方案之一,但它给我的答案不正确!

one of the solution i found the following, but it doesn't give me correct answer!

latitude = Math.PI * latitude / 180;
longitude = Math.PI * longitude / 180;

// adjust position by radians
latitude -= 1.570795765134; // subtract 90 degrees (in radians)

// and switch z and y 
xPos = (app.radius) * Math.sin(latitude) * Math.cos(longitude);
zPos = (app.radius) * Math.sin(latitude) * Math.sin(longitude);
yPos = (app.radius) * Math.cos(latitude);

我也尝试过此链接,但仍然不能很好地与我配合!

also i tried this link but still not work with me well!

任何帮助如何将(纬度,经度)转换为(x,y)吗?

any help how to convert from(latitude, longitude) to (x,y) ?

谢谢

推荐答案

不存在确切的解决方案

从球体到平面没有等轴测图.将平面中的纬度/经度坐标转换为平面中的x/y坐标时,您不能指望此操作将保留所有长度.您必须接受某种变形.确实存在许多不同的地图投影,这可以在长度,角度和面积的保留之间达成不同的折衷.对于地球表面的一小部分,横向墨卡托很常见.您可能已经听说过 UTM .但是还有更多.

No exact solution exists

There is no isometric map from the sphere to the plane. When you convert lat/lon coordinates from the sphere to x/y coordinates in the plane, you cannot hope that all lengths will be preserved by this operation. You have to accept some kind of deformation. Many different map projections do exist, which can achieve different compromises between preservations of lengths, angles and areas. For smallish parts of earth's surface, transverse Mercator is quite common. You might have heard about UTM. But there are many more.

您引用的公式将计算x/y/z,即3D空间中的一个点.但是即使到那里,您也不会自动获得正确的距离.球体表面上两点之间的最短距离将穿过该球体,而地球上的距离大部分是跟随该表面的测地线长度.这样它们会更长.

The formulas you quote compute x/y/z, i.e. a point in 3D space. But even there you'd not get correct distances automatically. The shortest distance between two points on the surface of the sphere would go through that sphere, whereas distances on the earth are mostly geodesic lengths following the surface. So they will be longer.

如果要绘制的地球表面部分相对较小,则可以使用非常简单的近似值.您可以简单地使用水平轴 x 表示经度λ,垂直轴 y 表示纬度φ.但是,两者之间的比例不应为1:1.相反,您应该使用cos(φ 0 )作为纵横比,其中φ 0 表示靠近地图中心的纬度.此外,要从角度(以弧度为单位)转换为长度,请乘以地球半径(在此模型中假定为球形).

If the part of the surface of the earth which you want to draw is relatively small, then you can use a very simple approximation. You can simply use the horizontal axis x to denote longitude λ, the vertical axis y to denote latitude φ. The ratio between these should not be 1:1, though. Instead you should use cos(φ0) as the aspect ratio, where φ0 denotes a latitude close to the center of your map. Furthermore, to convert from angles (measured in radians) to lengths, you multiply by the radius of the earth (which in this model is assumed to be a sphere).

  • x = r λcos(φ 0 )
  • y = r φ
  • x = r λ cos(φ0)
  • y = r φ

这是简单的 equirectangular投影.在大多数情况下,您只能计算一次cos(φ 0 ),这使得后续对大量点的计算确实很便宜.

This is simple equirectangular projection. In most cases, you'll be able to compute cos(φ0) only once, which makes subsequent computations of large numbers of points really cheap.

这篇关于从纬度,经度转换为x,y的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆