[GIS] Convert Lat/Lon sexagesimal degrees to UTM coordinates

coordinate systemcoordinatesepsgjavascriptproj4js

I'm using proj4.js to convert geographic coordinates (degrees, minutes and seconds) to UTM coordinates (ETRS89 Zone 30). When I get my coordinates result of the transformation I'm checking them with several web coordinates converters and I never get the same result (I mean really different coordinates) so I don't know if I'm doing something wrong or what.

To make the conversion, I first transform the coordinates from degrees, minutes, seconds to decimal degrees and then make the conversion like this:

var firstProjection = "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs";
this.secondProjection = "+proj=utm +zone=30 +ellps=GRS80 +units=m +no_defs";
var longLat = this.toDecimalsDegrees(); //Array with coordinates in decimal degrees

var result = proj4(firstProjection, this.secondProjection, [longLat[0], longLat[1]]);

Finally, it is correct the longitude coordinate first and latitude then?


The coordinates I'm using are:

Longitude: 6º 2' 32.929''
Latitude: 37º 21' 41.131''

And once I have converted them to decimal degrees:

Longitude: 6.042480466276646
Latitude: 37.361425499749146

The result of the reprojection that I get with the code mentiones above is:

X: 1301616.242
Y: 4173536.779

Meanwhile in other web conversors the rresult is:

X: 761940.319
Y: 4139140.14

Best Answer

The conversion you did was correct, as in, your lat/lon in ETRS89 30N does indeed translate to (1301616.242, 4173536.779).

The problem is in the zone you are using. UTM zones go from -3º to +3º from your central meridian, which is set at 500km, in the X axis. At 37º of latitude, each 1º is about 88.5km, meaning the entire zone spans from 234.5km to 765.5km. If your point is beyond that, it's time to change zones. Which is exactly what is happening.

Your derived coordinates at zone 30N have an X of 1301616.242m, that is way more than what's acceptable, and you should change zones. Converting to zone 31N, you get an X of 768365m, which is pretty close to the value that this other web conversor used. Hence, the conversor probably identified the correct zone, and translated accordingly.

One other thing that is to note is that, as user Marco mentioned in the comments, it may be that your longitude is wrong, as in, it should be -6º (6º west) where it's written 6º. This way, using Zone 30N would be correct (incidently, your X in this setup would be about 230525m).