【发布时间】:2020-10-13 03:11:45
【问题描述】:
import geopandas as gpd
DATA = gpd.read_file('Africa.shx')
DATA.info()
我从this website、Africa.shx 和Africa.shp 下载了两个 shapefile。 我如何知道包括哪些国家?例如,指数从 0 到 58,但非洲只有 55 个国家(包括西撒哈拉)。另外,我应该如何将每个国家的数据与 shapefile 匹配?我认为这也是由索引完成的,因此了解它们的含义非常重要。顺便说一句,哪种文件类型更便于处理此类匹配作业,.shx 或 .shp?
<class 'geopandas.geodataframe.GeoDataFrame'>
RangeIndex: 59 entries, 0 to 58
Data columns (total 1 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 geometry 59 non-null geometry
dtypes: geometry(1)
memory usage: 600.0 bytes
【问题讨论】:
-
您需要
Africa.dbf文件。那是存储名称等数据的地方。如果您在一个文件夹中有shp,shx` 和dbf,那么gpd.read_file('Africa.shp')应该可以正确加载它们。 -
@martinfleis 谢谢!它不起作用,因为我将长文件名更改为
Africa...不知道.dbf很重要。现在一切都好。非常感谢! -
@martinfleis 你可以把它变成一个答案,如果你愿意,我会接受。
标签: python shapefile geopandas