This repository contains a Python project that creates an interactive world choropleth map showing the population density of each country (people per square kilometer) for 2025.
The script WorldChoroplethPopulationDensityMap.py uses Plotly Express
to visualize population density data.
It applies a logarithmic transformation to density values to improve color contrast on the map.
When hovering over a country, the map shows both the actual density and the log-scaled value.
The project uses the following datasets:
-
Original datasets from Gapminder:
population_density_per_square_km.csvpopulation_density_per_square_km.xlsx
These were downloaded from Gapminder Data using the search term "population density (per square km)".
They contain population density for all countries and for all years, including 2025.
-
Modified datasets for 2025 used by the script:
population_density_per_square_km_2025.csvpopulation_density_per_square_km_2025.xlsx
These files were created from the original Gapminder datasets by removing all columns except two: the country names and the population density for 2025.
All data for previous years were deleted.
The script generates an interactive choropleth map and saves it as:
Population_density_map_by_country.html
You can open this HTML file in any web browser to explore the population density of each country.
Below is a snapshot of the map:
- Make sure all the required data files are in the same folder as the script.
- Run the script using Python (Python 3.8+ recommended).
- The interactive map will open automatically and the HTML file will be saved in the same folder.
- Python 3.8 or higher
- pandas
- numpy
- plotly
