Use the GDAL library in Python to obtain the EPSG code of the coordinate system through the coordinate system data in WKT format:
from osgeo import osr
def get_epsg_from_wkt(wkt):
spatial_ref = osr.SpatialReference()
spatial_ref.ImportFromWkt(wkt)
epsg = spatial_ref.GetAuthorityCode(None)
return int(epsg)
# WKT格式的坐标系数据
wkt_data = 'PROJCS["WGS 84 / UTM zone 31N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],AUTHORITY["EPSG","32631"],AXIS["Easting",EAST],AXIS["Northing",NORTH]]'
# 获取EPSG代码
epsg_code = get_epsg_from_wkt(wkt_data)
print(epsg_code)
gdal version: 3.2.1