如何使用 PROJ.4 将 WGS84 坐标转换为投影中的坐标?
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
55是纬度还是经度?
编辑:看来你应该简单地交换纬度和经度参数。
编辑2:即
55 is latitude or longitude?
EDIT: it seems you should simply swap lat and long parameters.
EDIT2: i.e.