How to transform coordinate from WGS84 to a coordinate in a projection with PROJ.4?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 18:54:23

问题


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.


回答1:


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); 


来源:https://stackoverflow.com/questions/2469583/how-to-transform-coordinate-from-wgs84-to-a-coordinate-in-a-projection-with-proj

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!