Life expectancy in Poland

Generating Interactive HTML Hexagonal maps with python

In this project I created interactive HTML maps to visualize life expectancy across various voivodeships of Poland. The process of generating these maps involves several steps:

  1. Data Preparation:
    • Load demographic data from an Excel file containing information on life expectancy for men and women across different age groups.
    • Load a shapefile containing the administrative boundaries of Poland’s voivodeships.
  2. Data Processing:
    • Remove unnecessary columns and merge demographic data for men and women.
    • Correct the voivodeship names to ensure consistency between the demographic and geographic data.
  3. Creating Hexagons:
    • Generate hexagons using the h3-py library to cover the entire area of Poland.
    • Merge the demographic data with the geographic data, assigning life expectancy values to the appropriate hexagons.
  4. Creating Interactive Maps:
    • Use the plotly library to create interactive maps with hexagons.
    • For each age group and gender, generate a map where the color of each hexagon corresponds to the life expectancy value.
    • Add interactive tooltips containing the voivodeship name and life expectancy value.
  5. Saving Maps:
    • Each interactive map is saved as an HTML file, which can be opened in any web browser.

Example command to run the script:

Bash
create_hex_map_interactive.py --shapefile_path "Shape Files/A01_Granice_wojewodztw.shp" --output_dir "hex_maps_interactive" --file_path "table_b_life_expectancy_in_poland_by_voivodships_in_2022.xlsx"

The final output consists of interactive maps that allow for easy and intuitive comparison of life expectancy across different regions of Poland.

The demographic data used in this project is sourced from the Life Expectancy Tables of Poland 2022 published by Statistics Poland (GUS). (Data from 2022.)

you can check the code I used to generate these visualizations on my github.