Ali Arsalan
Ali Arsalan

Reputation: 39

How to get Lat/Lon from x,y Cartesian Coordinates tmerc projection?

I am trying to convert data from OpenDrive Cartesian coordinates to Lat/Lon values. For pt = [6.714150516498e+05, 5.434880530093e+06] on the German A9 Highway, I want to know what the Lat/Lon Coordinates are.

I have been trying to solve it this way but I'm getting lat/lon coordinates of a desert in Nigeria.

from pyproj import Proj, transform
inProj = Proj("+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=500000 +y_0=0 +datum=WGS84 +units=m +no_defs")
outProj = Proj(init='epsg:4326', preserve_units=True)

w = [6.714150516498e+05, 5.434880530093e+06]

lat, lon = transform(inProj, outProj, w[0], w[1])
print(lat, lon)

Upvotes: 0

Views: 1414

Answers (1)

Maurice Meyer
Maurice Meyer

Reputation: 18106

transform returns (x,y). That means: x = lon, y = lat.

>>> print transform(inProj, outProj, w[0], w[1])[::-1]
(49.04294637744738, 11.345684678187824)

Which is somewhere in Germany next to a highway A9.

Upvotes: 4

Related Questions