UTM转经纬度python代码
时间: 2023-12-17 15:02:35 浏览: 234
以下是将UTM坐标系下的坐标转换为经纬度的Python代码,需要使用pyproj库:
```python
import pyproj
def utm_to_latlon(zone, easting, northing):
"""
Convert UTM coordinates to latitude and longitude.
:param zone: UTM zone (int).
:param easting: UTM easting (float).
:param northing: UTM northing (float).
:return: Tuple of latitude and longitude in decimal degrees (floats).
"""
p = pyproj.Proj(proj='utm', zone=zone, ellps='WGS84')
lon, lat = p(easting, northing, inverse=True)
return lat, lon
```
使用示例:
```python
lat, lon = utm_to_latlon(32, 377847, 3974541)
print(lat, lon) # 39.913938, 116.391423
```
其中,`zone`为UTM坐标系下的区域编号,`easting`和`northing`分别为UTM坐标系下的东北坐标。返回的`lat`和`lon`为转换后的经纬度坐标。
阅读全文