问题:python 通过cartopy.io.shapereader读取shp文件,出现Incomplete shapefile definition in 'c:\aaa.dbf'
ditubianjie = ccrs.PlateCarree() # 定义投影转换
fname = 'aaa.dbf'
features = shpreader.Reader(file).geometries()
# 绘制地图
ax.add_geometries(features , ditubianjie, facecolor='none', edgecolor='black', zorder=2)
解决:将shp文件(.shp,.dbf,.shx等)放在同一目录就可以了。
原因:扒拉开源代码就是这么写的,如下:
if reader.shp is None or reader.shx is None or reader.dbf is None:
raise ValueError("Incomplete shapefile definition "
"in '%s'." % filename)
cartopy.io.shapereader — cartopy 0.12.0 documentation (scitools.org.uk)