How to convert UTM to Lat/Long?

Josh picture Josh · Apr 21, 2010 · Viewed 23.8k times · Source

Is there a way to convert UTM to Lat/Long in Javascript? I have seen another thread on this but it was in Java and Python which won't help me much. Please let me know, thanks.

Answer

Richard picture Richard · Sep 4, 2013

You could use Proj4js, as follows.

Download Proj4JS from GitHub, using this link.

The following code will convert from UTM to longitude latitude

<html>
<head>
  <script src="proj4.js"></script>

  <script>
    var utm = "+proj=utm +zone=32";
    var wgs84 = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
    console.log(proj4(utm,wgs84,[539884, 4942158]));
  </script>
</head>
<body>

</body>
</html>

In this code, the UTM zone is 32, as should be obvious. The Easting is 539884, and the Northing is 4942158. The result is:

[9.502832656648073, 44.631671014204365] 

Which is to say 44.631671014204365N, 9.502832656648073E. Which I have verified is correct.

If you need other projections, you can find their strings here.