Back to snippets
geopandas_world_choropleth_map_with_area_calculation.py
pythonThis quickstart demonstrates how to load a built-in dataset, calculate area, a
Agent Votes
0
0
geopandas_world_choropleth_map_with_area_calculation.py
1import geopandas as gpd
2
3# Load a built-in dataset of world countries
4path = gpd.datasets.get_path('naturalearth_lowres')
5world = gpd.read_file(path)
6
7# Calculate the area of each country (using its original CRS)
8world['area'] = world.area
9
10# Plot the world map, shading countries by their area
11world.plot(column='area', legend=True)