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

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

问题描述

我想将GPS位置(纬度,经度)转换为x,y坐标。
我发现了很多关于这个主题的链接并应用了它,但它并没有给我正确的答案!



我正在按照这些步骤来测试答案:
(1)首先,我采取两个职位并使用地图计算他们之间的距离。
(2)然后将这两个位置转换为x,y坐标。
(3)然后再次计算x,y坐标
中两点之间的距离,看看它是否给了第(1)点相同的结果。



其中一个解决方案是我找到了以下内容,但它并没有给我正确答案!

 纬度= Math.PI *纬度/ 180; 
longitude = Math.PI * longitude / 180;

//通过弧度调整位置
latitude - = 1.570795765134; //减90度(弧度)

//开关z和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);

我也试过这个 link ,但仍然无法与我一起工作!



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



感谢,

解决方案

没有确切的解决方案



从球面到飞机没有等轴测图。将平面中的纬度/经度坐标转换为平面中的x / y坐标时,不能希望通过此操作保留所有长度。你必须接受某种变形。确实存在许多不同的地图投影,这可以在保存长度,角度和面积之间实现不同的折衷。对于地表的小部分地区,横向墨卡托是相当普遍的。您可能听说过 UTM 。但还有更多



您引用的公式x / y / z,即3D空间中的一个点。但即使在那里,你也无法自动获得正确的距离。球体表面上两点之间的最短距离将穿过该球体,而地球上的距离大部分是测量表面之后的测地线长度。所以它们会更长。

小区域的近似值



如果地球表面的一部分你想画的比较小,那么你可以使用一个非常简单的近似。您可以简单地使用水平轴 x 表示经度λ,垂直轴 y 表示纬度φ。不过,它们之间的比例不应该是1:1。相反,您应该使用cos(φ 0 )作为宽高比,其中φ 0 表示接近地图中心的纬度。此外,为了从角度(以弧度测量)转换为长度,您乘以地球的半径(在此模型中假定为球体)。


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



这很简单等矩形投影。在大多数情况下,您只能计算一次cos(φ 0 ),这使得大量点的后续计算非常便宜。

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!

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!

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

Thanks,

解决方案

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.

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.

Approximation for small areas

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 φ

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天全站免登陆