Coordinates transformation from SWEREF 99 to WGS84

Hi, I have a bunch of coordinate points in SWEREF 99, and I’d like to transfer them into WGS84. I have searched some available libraries from the internet, only to find swift - Converting from coordinate system WGS84 to SWEREF991330 - Stack Overflow and python - From SWEREF99 to EPSG:3857 - Geographic Information Systems Stack Exchange. I think I can reverse the method from the first link. On the other hand, can anyone please let me know is there any available julia code to accomplish this?

Try Proj4.jl

using Proj4

wgs84 = Projection("+proj=longlat +datum=WGS84 +no_defs")
utm56 = Projection("+proj=utm +zone=56 +south +datum=WGS84 +units=m +no_defs")

transform(wgs84, utm56, [150 -27 0])
# Should result in [202273.913 7010024.033 0.0]

I did not see SWEREF 99 anywhere.

Use to find the EPSG code, then there is a dict Proj4.epsg which will hopefully translate that code into a proj4 string.


Was wondering, does anyone know Proj4 converter?
I tried the command cs2cs +init=epsg:3006 +no_defs +to +init=epsg:4326 +no_defs coordinates.txt,
and got a bunch of outputs, which I do not quite understand what they are…

$ cs2cs +init=epsg:3006 +no_defs +to +init=epsg:4326 +no_defs coordinates.txt
10d30'40.522"E	0dN 0.000larmposition x,larmposition y
17d33'40.793"E	0dN 0.000,7.19448148418837e6
17d40'3.376"E	0dN 0.000,7.21988343646516e6
17d25'29.983"E	0dN 0.000,7.20959774471198e6
17d36'29.595"E	0dN 0.000,7.2182703708029e6
17d36'2.597"E	0dN 0.000,7.22561205720193e6
17d31'26.793"E	0dN 0.000,7.18873783652116e6
17d33'10.109"E	0dN 0.000,7.19385142167459e6
17d34'20.149"E	0dN 0.000,7.19444530312765e6
17d34'25.281"E	0dN 0.000,7.15945920790433e6
17d32'25.261"E	0dN 0.000,7.19454516649317e6
17d32'19.864"E	0dN 0.000,7.19335815435032e6
17d29'43.801"E	0dN 0.000,7.20401550251234e6
17d40'13.158"E	0dN 0.000,7.18812460329629e6
17d37'4.517"E	0dN 0.000,7.15379228276333e6
17d40'19.921"E	0dN 0.000,7.18798150244436e6
17d32'51.817"E	0dN 0.000,7.2025377089298e6
17d32'18.651"E	0dN 0.000,7.19271398962223e6
17d33'6.051"E	0dN 0.000,7.19435427567905e6
17d30'37.999"E	0dN 0.000,7.19543755088655e6
17d29'32.98"E	0dN 0.000,7.19404307413288e6
17d39'53.169"E	0dN 0.000,7.18955500355098e6
17d38'14.134"E	0dN 0.000,7.22685690615503e6
17d33'3.387"E	0dN 0.000,7.19360020265149e6
17d32'58.719"E	0dN 0.000,7.19339257233977e6
17d34'15.965"E	0dN 0.000,7.19463385008022e6
17d32'44.994"E	0dN 0.000,7.19474779953873e6
66d22'10.141"E	0dN 0.000,782534.696
17d19'10.04"E	0dN 0.000,7.22322474846404e6
17d33'58.492"E	0dN 0.000,7.193697542983e6
17d31'29.403"E	0dN 0.000,7.19422971392191e6
17d33'43.27"E	0dN 0.000,7.19359708334463e6
17d32'32.81"E	0dN 0.000,7.19447076571649e6
17d33'55.479"E	0dN 0.000,7.19512124467439e6
17d33'5.355"E	0dN 0.000,7.19262982617056e6
17d32'53.744"E	0dN 0.000,7.19452923299976e6
17d38'27.871"E	0dN 0.000,7.21370213104383e6
17d33'27.856"E	0dN 0.000,7.18947209967438e6
17d48'53.038"E	0dN 0.000,7.15608942210657e6
17d34'32.906"E	0dN 0.000,7.19161764790031e6
17d32'47.716"E	0dN 0.000,7.19455233998783e6
17d32'39.475"E	0dN 0.000,7.17392702706306e6
17d34'3.55"E	0dN 0.000,7.19441996768128e6

A search tells me that SWEREF is from Sweden and is a UTM projection but your longitude is 150. Way far from the utm zone 33 (center longitude is 12 degrees East). And is for the Northern hemisphere but you latitude is -27. When I try with GMT.jl with zone 56 like in your example I get the same Easting as you wish but the Northing is … somewhere.

using GMT

mapproject([150 27], proj="+proj=utm+zone=56+ellps=GRS80+towgs84=0,0,0,0,0,0,0+units=m+no_defs")
1-element Array{GMT.GMTdataset,1}:
 GMT.GMTdataset([202273.91299404675 2.9899759667982454e6], String[], "", String[], "", "")

Hi, the example I attached is just from the website, it’s not my example. So, if SWEREF is an UTM projection, then which is the parameter to use? I mean, the parameter as 56 in utm56?

Hi, I tried to convert it using the following link:
For the converted data, the latitude and longitude of the points are gathered together, really strange. Do you know how to find out the projection of SWEREF of a country or an area based on the data?

No. For Sweden you should use +zone=33 (UTM33). Each UTM zone is 6 degrees and the projection center is at the middle of that interval. Thus UTM1 covers from -180 to -174 and center at -177. Since Sweden spans ~10 to ~24, zone 33 is the best. But there are some exceptions at high latitudes that I don’t remember right now.

Anyway the link that I posted says that SWEREF99 is UTM33 and this is the one you should use. But not if your points falls so far outside, like the example point [150 -27]. For that point the UTM33 is really a bad projection to use.

@joa-quim you are right of course that 150, -27 is not near Sweden and thus not applicable. I see that these coordinates come out of the Proj4.jl tests, so it’s not the actual data.

@bsnyh you mention you want to go from SWEREF 99 to WGS84. I see from your cs2cs example that you already found these correspond to EPSG:3006 and EPSG:4326 respectively. That means we are almost there. We can use these EPSG codes to create the projections. I found that the center of Stockholm in EPSG:3006 is 674730, 6580270, so I use that as an example:

using Proj4

sweref99tm = Projection(Proj4.epsg[3006])
wgs84 = Projection(Proj4.epsg[4326])

point_sweref99tm = [674730, 6580270]
point_wgs84 = transform(sweref99tm, wgs84, point_sweref99tm)
point_wgs84  # -> [18.070991993333237, 59.324992984694404]

As you can verify, those coordinates are in the same location, but a different projection.


Hi. Thank you for your clarifications. I’m not exactly sure that this corresponds to EPSG:3006 and EPSG:4326. How to be certain?

1 Like

Thank you. I will try it out with EPSG:3006 and EPSG:4326 respectively. The SWEREF 99 data I got is a simulated data.