Solve the problem of coordinate transformation of Python GDAL projection

Time:2020-9-16

To convert the xian80 geographic coordinate system to a projected coordinate system:


xian1980 = """
GEOGCS["GCS_Xian_1980",
  DATUM["Xian_1980",
    SPHEROID["Xian_1980",6378140.0,298.257]],
  PRIMEM["Greenwich",0.0],
  UNIT["Degree",0.0174532925199433]]"""
prjreference = 'PROJCS["Xian_1980_3_Degree_GK_Zone_37",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",37500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",111.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]'

Error will be reported after conversion:

latlong = transform.TransformPoint(x,y)
 File "/usr/lib/python3/dist-packages/osgeo/osr.py", line 711, in TransformPoint
  return _osr.CoordinateTransformation_TransformPoint(self, *args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'CoordinateTransformation_TransformPoint'.
 Possible C/C++ prototypes are:
  OSRCoordinateTransformationShadow::TransformPoint(double [3])
  OSRCoordinateTransformationShadow::TransformPoint(double [3],double,double,double)

**If you think about it, you haven't found this problem before**
'PROJCS["Xian_1980_3_Degree_GK_Zone_37",GEOGCS["GCS_Xian_1980",DATUM["D_Xian_1980",SPHEROID["Xian_1980",6378140.0,298.257]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",37500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",111.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]'

**It is not Gauss Kruger projection, but transverse Mercator projection. I think the reason is that GDAL library can only support Gauss Kruger projection. * *

The above article to solve the problem of transformation of Python GDAL projection coordinate system is the entire content shared by the editor. I hope to give you a reference, and I hope you can support developeppaer more.