UTM(xy坐标)转WGS经纬度坐标方法

 python方法UTM转经纬度坐标:

例:上海带号51度带,北半球

(326474.4650588095, 3392563.1296714176)   ===>   (30.6531625008, 121.1890005577)

import math
from pyproj import Proj


def transform_utm_into_lat_lon(x, y, zone, hemisphere):

    # verify the hemisphere
    h_north = False
    h_south = False
    if (hemisphere == 'N'):
        h_north = True
    elif (hemisphere == 'S'):
        h_south = True
    else:
        print("Unknown hemisphere: " + hemisphere)

    proj_in = Proj(proj = 'utm', zone = zone, ellps = 'WGS84', south = h_south, north = h_north, errcheck = True)

    lon, lat = proj_in(x, y, inverse = True)

    # just printing the floating point number with 6 decimal points will round it
    lon = math.floor(lon * 1000000) / 1000000
    lat = math.floor(lat * 1000000) / 1000000

    lon = "%.6f" % lon
    lat = "%.6f" % lat

    return lon, lat

调用即可

你可能感兴趣的:(python)