不同坐标系下,点的转换函数。以备查阅
python
# -*- coding:utf-8 -*-
# 定义坐标转换函数
import pandas as pd
import pyproj
WGS84= r"GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],AUTHORITY[\"EPSG\",\"4326\"]]"
EPSG4549 = r'PROJCS["CGCS2000_3_Degree_GK_CM_120E",GEOGCS["GCS_China_Geodetic_Coordinate_System_2000",DATUM["D_China_2000",SPHEROID["CGCS2000",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",120.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]'
Test = 'PROJCS["CGCS2000_3_Degree_GK_CM_120E",GEOGCS["GCS_China_Geodetic_Coordinate_System_2000",DATUM["D_China_2000",SPHEROID["CGCS2000",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",120.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",4549]]'
# def convert_to_cgcs2000(lat, lon):
def convert_to_cgcs2000(lon,lat):
# transformer = pyproj.Transformer.from_crs("epsg:4326", "epsg:4521", always_xy=True)
# transformer = pyproj.Transformer.from_crs("epsg:4326", "epsg:4543", always_xy=True)
# transformer = pyproj.Transformer.from_crs(WGS84, CGCS2000_3_120, always_xy=True)
transformer = pyproj.Transformer.from_crs(WGS84, Test, always_xy=True)
cgcs2000_lon, cgcs2000_lat = transformer.transform(lon, lat)
return cgcs2000_lat, cgcs2000_lon
if __name__ == '__main__':
Lng = 120.557994
Lat = 24.292394
cgcs2000_lat, cgcs2000_lon = convert_to_cgcs2000(Lng,Lat)
print("Lng:{},Lat:{},cgcs2000_lat:{}, cgcs2000_lon:{}".format(Lng,Lat,cgcs2000_lat, cgcs2000_lon))