Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

an unexpected error with the 'shapefile' #3

Open
tomaszek0 opened this issue Feb 7, 2024 · 1 comment
Open

an unexpected error with the 'shapefile' #3

tomaszek0 opened this issue Feb 7, 2024 · 1 comment

Comments

@tomaszek0
Copy link

I have encountered an error while trying to load a shapefile with world coordinates "ne_110m_admin_0_countries.shp" and the corresponding .shx (v5.1.1). I followed the code in your 'obesity.ipnyb' file, which included the following code:

import geopandas as gpd
shapefile = 'countries_110m/ne_110m_admin_0_countries.shp'
gdf = gpd.read_file(shapefile)[['ADMIN', 'ADM0_A3', 'geometry']]

However, when I executed this code, I received the following error: "KeyError: "['ADMIN', 'ADM0_A3'] not in index".
I also tried loading shapefile v4.0.1, but encountered the same error.
When I loaded the file using the following code, it only contained the 'geometry' column:

gdf = gpd.read_file(shapefile)
gdf.head()
@tomaszek0
Copy link
Author

Ah, I figured it out - I need the entire geodata archive unpacked - not individual shp and shx files.

shapefile = 'geodata\ne_110m_admin_0_countries.shp'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant