techPython

python

use python show a world map

Install dependency

pip install geopandas matplotlib

Main python code map.py

# map.py
import geopandas as gpd
import matplotlib.pyplot as plt
 
# Load the world map dataset
world = gpd.read_file("./ne_110m_admin_0_countries/ne_110m_admin_0_countries.shp")
 
# Plot the world map
world.plot()
 
# Add title to the map
plt.title('World Map')
 
# Show the plot
plt.show()

Download the map data file

Extract the files and put them next to map.py

Now your file structure looks like this

In terminal, execute it with python .\map.py

Result:

Do not shoot this.