Diverging bar charts showing world population distribution by longitude, with configurable alignment latitude and regional groupings.
The default output shows population stacked by geographic region, with the equator as the horizontal axis. Northern hemisphere extends upward, southern hemisphere downward.
See tables/ for CSV data and graphs/ for visualizations.
Python 3.8+ with:
pip install numpy matplotlib colorcet
For the global map visualization (global_qN.py):
pip install cartopy shapely
Preprocessed data is included in input/. To preview a histogram:
python3 longitude_histogram.py
To save output files, provide a name:
python3 longitude_histogram.py regions
Output: tables/regions.csv and graphs/regions.png
python3 longitude_histogram.py output_name # file stem for output
python3 longitude_histogram.py --bin-width 5 # 5-degree longitude bins
python3 longitude_histogram.py --align p50 # split at population median
python3 longitude_histogram.py --align 45N # split at 45 degrees north
python3 longitude_histogram.py --no-regions # hemisphere mode (north/south only)
python3 longitude_histogram.py --markers # add markers from settings/place_markers.csv
See docs/longitude_histogram.md for full documentation.
Add labeled geographic reference points with --markers:
# Use baseline markers from settings/place_markers.csv
python3 longitude_histogram.py equator_1deg --markers
# Override specific markers for different alignments
python3 longitude_histogram.py 90s_1deg --align 90s --markers settings/custom_markers_90s.csv
python3 longitude_histogram.py p80_1deg --align p80 --markers settings/custom_markers_p80.csv
Override files merge with the baseline: same-name entries replace baseline entries, new names are added, and empty coordinates omit a marker. Format:
# Name,Latitude,Longitude,Symbol,Direction (0-360, clockwise from top)
Helsinki,60.1699,24.9384,◇,0
Réunion,,
Override country-to-region assignments with --regions:
python3 longitude_histogram.py output --regions settings/custom_regions.csv
Override files merge with settings/countries_regions.csv. Example:
# Separate Belarus and Ukraine from "Rest of Europe"
Belarus,Belarus
Ukraine,Ukraine

./longitude_histogram.py baseline
# Default: alignment at equator. Save as graphs/baseline.png, tables/baseline.csv
./longitude_histogram.py p50_2deg --bin-width 2 --align p50 --markers --svg
# Split at the median latitude of world population. Bin-width 2 degrees of longitude
./longitude_histogram.py 90s_2deg --bin-width 2 --align 90s --markers settings/custom_markers_90s.csv --svg
# Trivial split at 90 degrees South = ordinary bottom-aligned histogram. Custom marker label placements to prevent label overlap

./longitude_histogram.py p80_1deg --align p80 --regions settings/custom_regions.csv --markers settings/custom_markers_p80.csv
# Split at 80th percentile latitude of world population. Custom regions: Belarus, Ukraine.

./longitude_histogram.py q50_1deg --align q50 --markers settings/custom_markers_1deg.csv
# Split at each longitude-specific population median

./global_qN.py tables/q50_1deg.csv graphs/map_q50_1deg.png
# World map with longitude-specific population medians

./longitude_histogram.py hemispheres_60n --no-regions --bin-width 5 --align 60n
# North/South instead of regions, split at 60 degrees North
Population data from NASA SEDAC Gridded Population of the World (GPW) v4.11:
- Resolution: 30 arc-seconds (~1 km at equator)
- Year: 2020
- Aggregated to 15 arc-minutes (0.25 degrees) for visualization
Center for International Earth Science Information Network (CIESIN), Columbia University. 2018. Gridded Population of the World, Version 4 (GPWv4): Population Count Adjusted to Match 2015 Revision of UN WPP Country Totals, Revision 11. Palisades, NY: NASA Socioeconomic Data and Applications Center (SEDAC). https://doi.org/10.7927/H4PN93PB
The input/ directory contains preprocessed data ready to use. To regenerate
from raw GPW tiles:
-
Download GPW v4.11 data from https://sedac.ciesin.columbia.edu/data/set/gpw-v4-population-count-adjusted-to-2015-unwpp-country-totals-rev11
- Population Count (30 arc-second), ASCII format
- National Identifier Grid (30 arc-second), ASCII format
-
Extract to
data/directory -
Run preprocessing (~ 2 minutes):
python3 preprocess_gpw.py
See docs/preprocessing.md for details.
longitude_histogram.py # Main visualization script
global_qN.py # Map visualization for per-bin percentile splits
preprocess_gpw.py # Data preprocessing (optional)
input/ # Preprocessed data (included)
settings/ # Region mappings, colors, markers
docs/ # Documentation
tables/ # Output CSV files
graphs/ # Output image files
Code: MIT License
Output visualizations: CC BY-SA 4.0
Data: Subject to SEDAC terms of use (see Data Source above)