GIS Eden
Discover the beauty of GIS
Δ
selection.to_file(out) //这行代码出错,输出shp或者.geojson都不行
————————————————————————— CPLE_AppDefinedError Traceback (most recent call last) fiona/ogrext.pyx in fiona.ogrext.WritingSession.start()
fiona/_err.pyx in fiona._err.exc_wrap_int()
CPLE_AppDefinedError: Failed to create field name ‘����’: cannot convert to ISO-8859-1
During handling of the above exception, another exception occurred:
SchemaError Traceback (most recent call last) in —-> 1 selection.to_file(out)
~\Anaconda3\lib\site-packages\geopandas\geodataframe.py in to_file(self, filename, driver, schema, **kwargs) 502 from geopandas.io.file import to_file 503 –> 504 to_file(self, filename, driver, schema, **kwargs) 505 506 def to_crs(self, crs=None, epsg=None, inplace=False):
~\Anaconda3\lib\site-packages\geopandas\io\file.py in to_file(df, filename, driver, schema, **kwargs) 126 with fiona_env(): 127 with fiona.open( –> 128 filename, “w”, driver=driver, crs=df.crs, schema=schema, **kwargs 129 ) as colxn: 130 colxn.writerecords(df.iterfeatures())
~\Anaconda3\lib\site-packages\fiona\env.py in wrapper(*args, **kwargs) 394 def wrapper(*args, **kwargs): 395 if local._env: –> 396 return f(*args, **kwargs) 397 else: 398 if isinstance(args[0], str):
~\Anaconda3\lib\site-packages\fiona\__init__.py in open(fp, mode, driver, schema, crs, encoding, layer, vfs, enabled_drivers, crs_wkt, **kwargs) 261 c = Collection(path, mode, crs=crs, driver=driver, schema=this_schema, 262 encoding=encoding, layer=layer, enabled_drivers=enabled_drivers, crs_wkt=crs_wkt, –> 263 **kwargs) 264 else: 265 raise ValueError(
~\Anaconda3\lib\site-packages\fiona\collection.py in __init__(self, path, mode, driver, schema, crs, encoding, layer, vsi, archive, enabled_drivers, crs_wkt, ignore_fields, ignore_geometry, **kwargs) 160 elif self.mode in (‘a’, ‘w’): 161 self.session = WritingSession() –> 162 self.session.start(self, **kwargs) 163 except IOError: 164 self.session = None
fiona/ogrext.pyx in fiona.ogrext.WritingSession.start()
SchemaError: Failed to create field name ‘����’: cannot convert to ISO-8859-1
selection.to_file(out,encoding=’utf-8′,driver=’GeoJSON’),包含汉字的输出为GeoJson
OK,成功输出
GeoPandas你们都装上了么?我都装了整整两天了,怎么都装不上。。。。依赖的包太多了。动不动就出错。。。。要哭了。
geopandas相关的离线环境有文件下载离线安装
selection.to_file(out) //这行代码出错,输出shp或者.geojson都不行
—————————————————————————
CPLE_AppDefinedError Traceback (most recent call last)
fiona/ogrext.pyx in fiona.ogrext.WritingSession.start()
fiona/_err.pyx in fiona._err.exc_wrap_int()
CPLE_AppDefinedError: Failed to create field name ‘����’: cannot convert to ISO-8859-1
During handling of the above exception, another exception occurred:
SchemaError Traceback (most recent call last)
in
—-> 1 selection.to_file(out)
~\Anaconda3\lib\site-packages\geopandas\geodataframe.py in to_file(self, filename, driver, schema, **kwargs)
502 from geopandas.io.file import to_file
503
–> 504 to_file(self, filename, driver, schema, **kwargs)
505
506 def to_crs(self, crs=None, epsg=None, inplace=False):
~\Anaconda3\lib\site-packages\geopandas\io\file.py in to_file(df, filename, driver, schema, **kwargs)
126 with fiona_env():
127 with fiona.open(
–> 128 filename, “w”, driver=driver, crs=df.crs, schema=schema, **kwargs
129 ) as colxn:
130 colxn.writerecords(df.iterfeatures())
~\Anaconda3\lib\site-packages\fiona\env.py in wrapper(*args, **kwargs)
394 def wrapper(*args, **kwargs):
395 if local._env:
–> 396 return f(*args, **kwargs)
397 else:
398 if isinstance(args[0], str):
~\Anaconda3\lib\site-packages\fiona\__init__.py in open(fp, mode, driver, schema, crs, encoding, layer, vfs, enabled_drivers, crs_wkt, **kwargs)
261 c = Collection(path, mode, crs=crs, driver=driver, schema=this_schema,
262 encoding=encoding, layer=layer, enabled_drivers=enabled_drivers, crs_wkt=crs_wkt,
–> 263 **kwargs)
264 else:
265 raise ValueError(
~\Anaconda3\lib\site-packages\fiona\collection.py in __init__(self, path, mode, driver, schema, crs, encoding, layer, vsi, archive, enabled_drivers, crs_wkt, ignore_fields, ignore_geometry, **kwargs)
160 elif self.mode in (‘a’, ‘w’):
161 self.session = WritingSession()
–> 162 self.session.start(self, **kwargs)
163 except IOError:
164 self.session = None
fiona/ogrext.pyx in fiona.ogrext.WritingSession.start()
SchemaError: Failed to create field name ‘����’: cannot convert to ISO-8859-1
selection.to_file(out,encoding=’utf-8′,driver=’GeoJSON’),包含汉字的输出为GeoJson
OK,成功输出
GeoPandas你们都装上了么?我都装了整整两天了,怎么都装不上。。。。依赖的包太多了。动不动就出错。。。。要哭了。
geopandas相关的离线环境有文件下载离线安装