我从美国人口普查局下载了一个形状文件地图。它包含了我需要的所有必要信息,但是由于某种原因,我需要的特定地图出现了错误:
Traceback (most recent call last):
File "C:/Users/Leb/Desktop/Python/Kaggle/mapp.py", line 17, in <module>
shp_info = m.readshapefile('gis/cb_2014_us_state_5m', 'states', drawbounds=True)
File "C:\Program Files\Python 3.5\lib\site-packages\mpl_toolkits\basemap\__init__.py", line 2162, in readshapefile
raise ValueError('readshapefile can only handle 2D shape types')
ValueError: readshapefile can only handle 2D shape types
更具体地说,这些文件(点击这里)给我带来了错误。您可以看到,我下载了
5m
分辨率的形状文件。以下是我用来执行命令的代码:
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap as Basemap
m = Basemap(llcrnrlon=-119, llcrnrlat=22, urcrnrlon=-64, urcrnrlat=49,
projection='lcc', lat_1=33, lat_2=45, lon_0=-95)
shp_info = m.readshapefile('gis/cb_2014_us_state_5m', 'states', drawbounds=True)
问题:
- 我需要通过
Fiona
或者ArcGIS
将其转换为适当的格式吗? - 是否有比
basemap
更好的替代方案?