如何使用 PROJ.4 将 WGS84 坐标转换为投影中的坐标?

发布于 2024-08-25 14:13:52 字数 1522 浏览 7 评论 0原文

我在 WGS84 中有一个 GPS 坐标,我想使用 PROJ.4 或 JavaScript 中的 Proj4js

很难找到 PROJ.4 的文档以及如何使用它。如果您有好的链接,请将其作为评论发布。

SWEREF99 TM 的 PROJ.4 参数为 +proj=utm + zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs

我尝试使用 PROJ.4 Java 库,用于转换纬度:55° 00' N,经度:12° 45' E 并尝试使用此代码:

String[] proj4_w = new String[] {
 "+proj=utm",
 "+zone=33",
 "+ellps=GRS80",
 "+towgs84=0,0,0,0,0,0,0",
 "+units=m",
 "+no_defs"
};

Projection proj = ProjectionFactory.fromPROJ4Specification(proj4_w);  

Point2D.Double testLatLng = new Point2D.Double(55.0000, 12.7500);
Point2D.Double testProjec = proj.transform(testLatLng, new Point2D.Double());

这给了我一点 Point2D.Double[5197915.86288144, 1822635.9083898761] 但我应该是 N: 6097106.672, E: 356083.438 我做错了什么?我应该使用什么方法和参数?

正确的值取自 Lantmäteriet

我不确定 proj.transform(testLatLng, new Point2D.Double()); 是否是正确的方法。

I have a GPS-coordinate in WGS84 that I would like to transform to a map-projection coordinate in SWEREF99 TM using PROJ.4 in Java or Proj4js in JavaScript.

Its hard to find documentation for PROJ.4 and how to use it. If you have a good link, please post it as a comment.

The PROJ.4 parameters for SWEREF99 TM is +proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs

I have tried to use a PROJ.4 Java library for transforming Lat: 55° 00’ N, Long: 12° 45’ E and tried with this code:

String[] proj4_w = new String[] {
 "+proj=utm",
 "+zone=33",
 "+ellps=GRS80",
 "+towgs84=0,0,0,0,0,0,0",
 "+units=m",
 "+no_defs"
};

Projection proj = ProjectionFactory.fromPROJ4Specification(proj4_w);  

Point2D.Double testLatLng = new Point2D.Double(55.0000, 12.7500);
Point2D.Double testProjec = proj.transform(testLatLng, new Point2D.Double());

This give me the point Point2D.Double[5197915.86288144, 1822635.9083898761] but I should be N: 6097106.672, E: 356083.438
What am I doing wrong? and what method and parameters should I use instead?

The correct values is taken from Lantmäteriet.

I am not sure if proj.transform(testLatLng, new Point2D.Double()); is the right method to use.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清君侧 2024-09-01 14:13:52

55是纬度还是经度?

编辑:看来你应该简单地交换纬度和经度参数。

编辑2:即

 Point2D.Double testLatLng = new Point2D.Double(12.7500, 55.0000); 

55 is latitude or longitude?

EDIT: it seems you should simply swap lat and long parameters.

EDIT2: i.e.

 Point2D.Double testLatLng = new Point2D.Double(12.7500, 55.0000); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文