3

I have to deal with this: https://minkarta.lantmateriet.se/?e=493056&n=6795776&z=3&profile=karta&background=1&boundaries=false

This is a URL which uses "e" and "n" in the "SWEREF 99 TM" GPS format.

But I have standard MapBox GL JS GPS coordinates, in the variables "longitude" and "latitude". I guess it's the WSG-84 or something. Which most map systems use.

If I simply put those coordinates for "e" and "n" (either way), it goes to the completely wrong place on the map.

How do I translate them properly so they make sense to that map system?

0

2 Answers 2

5

Library proj4.js (http://proj4js.org/) is usually used for coordinated transformation in JS. To use it one needs CRS definition, which can be easily found on epsg.io site.

SWEREF 99 TM coordinate system has CRS code EPSG:3006, proj4 definition string is "+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs".

JS code to convert [lon, lat] coordinate [14.8704033, 61.2961005] to projected Swedish coordinates could then look something like:

proj4.defs("EPSG:3006","+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");
var epsg3006 = proj4("EPSG:3006");

var projCoords = proj4(epsg3006,[14.8704033, 61.2961005]);

If you have just a few coordinates to convert you can use epsg.io site for that: https://epsg.io/transform#s_srs=4326&t_srs=3006

0
0

Coordinates like 61°51'41.2"N 12° 42'52.9"E in your link are Degrees Minutes Seconds instead of Decimal Degrees. To get Decimal Degrees you would convert like this: 61+51/60+41.2/3600.

3
  • I don't understand that calculation. They are just integers. Not like you display them. What's the actual "algorithm"?
    – Lorraine M
    Apr 9, 2022 at 14:31
  • 61°51'41.2"N is in degrees minutes seconds format and would be converted to decimal degrees by 61°+51'/60+41.2"/3600.
    – Pointdump
    Apr 9, 2022 at 19:37
  • I do not see such coordinates in the link. Where did you get your degrees? What I see are metric coordinates in EPSG:3006 at location epsg.io/…. EDIT: Ok, I understand now, you clicked the map on the website.
    – user30184
    Apr 9, 2022 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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