首页 > 解决方案 > can't locate shapefile in basemap Python

问题描述

I put a shapefile "china.shp" in my working directory, I tried many ways to set the path to file for basemap to read it, like

m3= Basemap(llcrnrlon=77, llcrnrlat=14, urcrnrlon=140, urcrnrlat=51, projection='lcc', lat_1=33, lat_2=45, lon_0=100)
m3.readshapefile("Y:/Study/Research_Data/geoschem/china",  'china', drawbounds=True)
plt.show()

But the error is always cannot locate Y:/Study/Research_Data/geoschem/china.shx

Do you have any idea how to set the path, please? Thanks.

标签: pythonpython-3.xmatplotlib-basemap

解决方案


shapefile 通常带有辅助文件,例如“.shx”、“.dbf”、“.prj”。这里需要“.shx”来加载相应的 shapefile。如果您移动了 shapefile,则应该将其辅助文件移动到相同的位置。


推荐阅读