Search code examples
pythonshapefilegeopandas

How do I find out the meaning of index in a .shp or .shx shapefile?


import geopandas as gpd    

DATA = gpd.read_file('Africa.shx')
DATA.info()

I have two shapefiles downloaded from this website, Africa.shx and Africa.shp. How do I know which countries are included? For example, the index goes from 0 to 58, but Africa only has 55 countries (West Sahara counted). Also, how should I match data from each country to a shapefile? I think it's also done by the index, so very important to find out what they mean. BTW, which filetype is more convenient to deal with for such matching job, .shx or .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

Solution

  • You need Africa.dbf file for that. That is where data like names are stored. If you have shp, shx and dbf in one folder, then gpd.read_file('Africa.shp') should load it all correctly.