我正在处理 shp 文件,但在 shp 文件中保存地理数据框时遇到问题。
import pandas as pd
import numpy as np
import os
import geopandas
location = '/home/braulio/Documents/example.shp'
datos = geopandas.read_file(location, encoding='UTF-8')
我在处理数据时没有问题,但是当我尝试保存时
A.to_file(r"/home/braulio/Documents/example2.shp")
并返回错误:
ValueError Traceback (most recent call last)
<ipython-input-23-6a842789b4b4> in <module>
----> 1 A.to_file(r"/home/braulio/Documents/example2.shp")
~/anaconda3/envs/braulio/lib/python3.7/site- packages/geopandas/geodataframe.py in to_file(self, filename, driver, schema, **kwargs)
411 """
412 from geopandas.io.file import to_file
--> 413 to_file(self, filename, driver, schema, **kwargs)
414
415 def to_crs(self, crs=None, epsg=None, inplace=False):
~/anaconda3/envs/braulio/lib/python3.7/site-packages/geopandas/io/file.py in to_file(df, filename, driver, schema,**kwargs)
109 with fiona.open(filename, 'w', driver=driver, crs=df.crs,
110 schema=schema, **kwargs) as colxn:
--> 111 colxn.writerecords(df.iterfeatures())
112
113
~/anaconda3/envs/braulio/lib/python3.7/site-packages/fiona/collection.py in writerecords(self, records)
347 if self.mode not in ('a', 'w'):
348 raise IOError("collection not open for writing")
--> 349 self.session.writerecs(records, self)
350 self._len = self.session.get_length()
351 self._bounds = self.session.get_extent()
fiona/ogrext.pyx in fiona.ogrext.WritingSession.writerecs()
fiona/ogrext.pyx in fiona.ogrext.OGRFeatureBuilder.build()
ValueError: Invalid field type <class 'bytes'>