Python与坐标系转换
示例¶
4326转4978¶
代码:
import pyproj
lon = -74.6604194
lat = 40.3450248
alt = 50
transformer = pyproj.Transformer.from_crs("EPSG:4326", "EPSG:4978", always_xy = True)
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)
输出: