解决cartopy加载地图文件乱码的问题
- from cartopy.io.shapereader import Reader
- 修改Reader方法为可传递encoding参数
from cartopy.io.shapereader import Reader
reader = Reader(china_city, encoding=“GBK”) # 其中encoding为修改后添加的参数
- 进入Reader原始方法文件中 shapereader.py 修改如下粗体
class BasicReader:
“”"
Provide an interface for accessing the contents of a shapefile.
The primary methods used on a Reader instance are
:meth:~Reader.records
and :meth:~Reader.geometries
.
“”"
def init(self, filename, encoding=“utf-8”):
# Validate the filename/shapefile
self._reader = reader = shapefile.Reader(filename, encoding=encoding)
- 传参到shapefile.Reader原始方法shapefile.py中