2

当我尝试运行 GeoPandas to_file 时弹出错误。错误信息是:

Traceback (most recent call last):
  File "<pyshell#88>", line 1, in <module>
    df.to_file('psuedo.shp')
  File "C:\Python27\ArcGIS10.5\lib\site-packages\geopandas\geodataframe.py", 
    line 365, in to_file
    to_file(self, filename, driver, schema, **kwargs)
  File "C:\Python27\ArcGIS10.5\lib\site-packages\geopandas\io\file.py", line 
    64, in to_file
    schema=schema, **kwargs) as colxn:
  File "C:\Python27\ArcGIS10.5\lib\site-packages\fiona\__init__.py", line 
    183, in open
    enabled_drivers=enabled_drivers, crs_wkt=crs_wkt)
  File "C:\Python27\ArcGIS10.5\lib\site-packages\fiona\collection.py", line 
    156, in __init__
    self.session.start(self, **kwargs)
  File "fiona\ogrext.pyx", line 948, in fiona.ogrext.WritingSession.start
DriverIOError: 'utf8' codec can't decode byte 0xb9 in position 41: invalid 
start byte

查了相关问题,了解到这类错误通常是通过转换相关文件的编码来解决的。但我什至找不到 ogrext.pyx ......有人能帮帮我吗?我是python新手,使用python2.7

4

1 回答 1

0

在写入或读取文件时尝试使用wb或参数。rb

像这样:

with open("path to file", 'rb') as f:
  contents = f.read()
于 2018-05-26T12:56:38.487 回答