Skip to content

Instantly share code, notes, and snippets.

@bertt
Created August 20, 2022 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bertt/eb27c404149e3a5ecb9fe6499d52f99a to your computer and use it in GitHub Desktop.
Save bertt/eb27c404149e3a5ecb9fe6499d52f99a to your computer and use it in GitHub Desktop.
ecef2latlon using pyproj
import pyproj
lon = 1231256.4091099831
lat = -4800453.896456448
alt = 4000024.663498499
transformer = pyproj.Transformer.from_crs("EPSG:4978", "EPSG:4326")
print(transformer)
xyz = transformer.transform(lon, lat, alt)
print('Projected XY', xyz)
lonlat = transformer.transform(xyz[0], xyz[1], xyz[2], direction='INVERSE')
print('Lon Lat', lonlat)
Result:
proj=pipeline step inv proj=cart ellps=WGS84 step proj=unitconvert xy_in=rad xy_out=deg step proj=axisswap order=2,1
Projected XY (39.096413909747135, -75.61445288733434, -959.1868305588141)
Lon Lat (1231256.4091099836, -4800453.896456448, 4000024.663498508)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment