Created
October 21, 2012 18:46
-
-
Save juanluisrp/3928064 to your computer and use it in GitHub Desktop.
Convert from utm to lat,lon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// include the library | |
<script src="lib/proj4js-combined.js"></script> //adjust the path for your server | |
//or else use the compressed version | |
. . . | |
// creating source and destination Proj4js objects | |
// once initialized, these may be re-used as often as needed | |
var dest = new Proj4js.Proj('EPSG:4236'); //source coordinates will be in Longitude/Latitude | |
var zone29 = new Proj4js.Proj('EPSG:23029'); //destination coordinates in UTM zone 29 | |
var zone30 = new Proj4js.Proj('EPSG:23030'); //destination coordinates in UTM zone 30 | |
var zone31 = new Proj4js.Proj('EPSG:23031'); //destination coordinates in UTM zone 31 | |
. . . | |
// transforming point coordinates | |
var p = new Proj4js.Point(670848, 4120235); //any object will do as long as it has 'x' and 'y' properties | |
if(zone==29) { | |
Proj4js.transform(zone29, dest, p); //do the transformation. x and y are modified in place | |
} else if (zone == 30) { | |
Proj4js.transform(zone30, dest, p); | |
} else if (zone == 31) { | |
Proj4js.transform(zone31, dest, p); | |
} | |
//p.x and p.y are now EPSG:4326 lat and long in degrees |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment