当我尝试运行此 python 代码时:
def convertProjection(self,x,y,from_crs,to_crs):
crsSrc = QgsCoordinateReferenceSystem(from_crs)
crsDest = QgsCoordinateReferenceSystem(to_crs)
xform = QgsCoordinateTransform(crsSrc, crsDest)
pt = xform.transform(QgsPoint(x,y))
return pt.x, pt.y
# Remove the "EPSG:" part
from_crs = 3857
to_crs = 4326
x = -11705274.6374
y = 4826473.6922
lon, lat = self.convertProjection(x,y,from_crs,to_crs)
发生此错误:
/usr/bin/python3.5 /home/jithin/PycharmProjects/PythonTests/XYTOLatLong_Conversion.py
Traceback (most recent call last):
File "/home/jithin/PycharmProjects/PythonTests/XYTOLatLong_Conversion.py", line 36, in <module>
lon, lat = self.convertProjection(x,y,from_crs,to_crs)
NameError: name 'self' is not defined
任何帮助表示赞赏......谢谢......
相关分类