Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert UTM to Lat/Long? [duplicate]

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.

like image 939
Josh Avatar asked Oct 11 '25 07:10

Josh


1 Answers

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.

like image 148
Richard Avatar answered Oct 13 '25 19:10

Richard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!