5

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

  • 1
    Providing details of the different results would help. As far as your question goes, it would be a matter of a few seconds' work to reverse the lat and lon coordinates and see how the result changes: did you try that? What were the results? Another possibility is an error in conversion from DMS to DD, but again you need to post the details. – whuber Dec 22 '17 at 17:10
  • @whuber thanks for answer I've updated the info in order to make it more clear to check it. – Fran1911989 Dec 27 '17 at 9:14
  • 1
    You might be missing a minus sign or you are in the wrong utm zone. The Zone 30 goes between -6º and 0º. – Marco Dec 29 '17 at 13:07
  • It was indeed because of the minus sign...I didn't realize. Thank you! – Fran1911989 Jan 3 '18 at 12:18
1

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).

  • As user Marco mentioned the problem was the minus sign. Now it works fine so the conversion of proj4.js was fine for the given coordinates at the begining. Thank you for your anwer! – Fran1911989 Jan 3 '18 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.