0

我正在尝试使用 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
4

1 回答 1

0

我会认真看看QGIS。它基于 python,但具有所有复杂的部分以及所有投影库和文件。如果你有很多文件要修复/修改 QGIS 还内置了 python 脚本。老实说,当涉及到映射时,不要尝试重新发明轮子。

https://www.qgis.org/en/site/

另请参阅https://gis.stackexchange.com/

于 2019-08-05T18:34:07.533 回答