How to transform coordinate from WGS84 to a coordinate in a projection in PROJ.4?
Posted
by Sanoj
on Stack Overflow
See other posts from Stack Overflow
or by Sanoj
Published on 2010-03-18T11:59:46Z
Indexed on
2010/03/18
12:01 UTC
Read the original article
Hit count: 413
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 us 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 and tried this code and values:
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.
© Stack Overflow or respective owner