我正在尝试使用 python 代码将我的 shapefile 的投影从“epsg:26741”更改为“epsg:4326”。我已经在网上查找了如何执行此操作并找到了一些代码,但是当我运行代码时,它会抛出一条错误消息。这在下面的代码中专门抛出:
from pyproj import Transformer
x = 5.0
y = 6.0
transformer = Transformer.from_crs("epsg:26741", "epsg:4326")
new_x, new_y = transformer.transform(x, y)
这会生成以下错误消息:
runfile('/Users/isaak/Desktop/GIS_Layer_Programs/TestTransform.py', wdir='/Users/isaak/Desktop/GIS_Layer_Programs')
Traceback (most recent call last):
File "<ipython-input-108-6daf357ca70c>", line 1, in <module>
runfile('/Users/isaak/Desktop/GIS_Layer_Programs/TestTransform.py', wdir='/Users/isaak/Desktop/GIS_Layer_Programs')
File "//anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "//anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/Users/isaak/Desktop/GIS_Layer_Programs/TestTransform.py", line 6, in <module>
new_x, new_y = transformer.transform(x, y)
File "//anaconda3/lib/python3.7/pyproj/transformer.py", line 274, in transform
File "pyproj/_transformer.pyx", line 122, in pyproj._transformer._Transformer._transform
File "//anaconda3/lib/python3.7/enum.py", line 310, in __call__
return cls.__new__(cls, value)
File "//anaconda3/lib/python3.7/enum.py", line 571, in __new__
raise exc
TypeError: error in TransformDirection._missing_: returned <TransformDirection.FORWARD: 'FORWARD'> instead of None or a valid member