I have a bunch of files with coordinates in UTM form. For each coordinate I have easting, northing and zone. I need to convert this to LatLng for use with Google Map API to show the information in a map.
I have found some online calculators that does this, but no actual code or libraries. http://trac.osgeo.org/proj4js/ is a projection library for Javascript, but looking at the demo it doesn't include UTM projection.
I am still pretty fresh to the entire GIS domain, so what I want is something ala:
(lat,lng) = transform(easting, northing, zone)
You could use Proj4js, as follows.
Download Proj4JS from GitHub, using this link.
The following code will convert from UTM to longitude latitude
In this code, the UTM zone is 32, as should be obvious. The Easting is 539884, and the Northing is 4942158. The result is:
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.
I'm new to this as well and have been studying up on the subject recently.
Here's a method I found using the python gdal pacakge (the osr package is included in gdal). The gdal package is pretty powerful, but the documentation could be better.
This is derived from a discussion here: http://www.mail-archive.com/gdal-dev@lists.osgeo.org/msg12398.html
And here's the method for converting from a lat, lon in wgs84 (what most gps units report) to utm:
I also found that if you've already got django/gdal installed and you know the EPSG code for the UTM zone you're working on, you can just use the
Point()
transform() method.What I found is the following site: http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html It has a javascript converter, you should check the algorithm there. From the page:
A Javascript version of Staale answer
There is a perl module via CPAN called Geography::NationalGrid which can convert easting/northing to lat/longs. That may help.
Alternatively there are lots of scripts on the movable-type site that let you convert lat/long and easting/northings.