This repository contains tools for generating Latino Climate and Health Dashboard Factsheets. The scripts are used to create data visualizations, maps, and comprehensive factsheets on environmental health disparities affecting Latino communities in California.
The data used in these factsheets was curated by the Data and Research team at the UCLA Latino Policy and Politics Institute (LPPI) and can be found from this Google Sheet: https://docs.google.com/spreadsheets/d/e/2PACX-1vTyGBCxXjMIztPF1IL5JrP0nss-H4GwJwyecXDRy7Hv5oyC3s54ytPaNotzoqTMKzkPCxFqgEItfSLz/pub?gid=1869860862&single=true&output=csv
The UCLA LPPI Factsheet Generator creates comprehensive factsheets that include:
wkhtmltopdf: Download here
geckodriver: Download here and add to PATH
Alternatively, for chrome, use chromedriver: Download here
git clone https://github.com/ucla-lppi/report-generator.git
cd report-generator
conda create --name report-generator python=3.8
conda activate report-generator
conda activate report-generator ```
pip install -r requirements.txt
Install system dependencies (optional, for PDF generation):
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install wkhtmltopdf firefox-geckodriver
macOS:
brew install wkhtmltopdf geckodriver
Windows:
Test your installation:
python -c "from report_generator import quick_demo; quick_demo(offline_mode=True)"
Generate factsheets using the original interface:
# Generate all factsheet types for all counties
python main.py build
# Generate specific factsheet type
python main.py build -t extremeheat
python main.py build -t airpollution
# Serve factsheets locally for preview
python main.py serve
Use the simplified ReportGenerator class:
from report_generator import ReportGenerator
# Quick demo (offline mode)
from report_generator import quick_demo
results = quick_demo(offline_mode=True)
# Full workflow
generator = ReportGenerator()
generator.load_data()
# Generate step by step
generator.generate_population_charts(['Los Angeles'])
generator.generate_heat_maps(['Los Angeles'])
generator.generate_air_pollution_maps(['Los Angeles'])
generator.generate_html_factsheets('all', ['Los Angeles'])
generator.generate_pdfs('all', ['Los Angeles'])
# Or generate everything at once
results = generator.generate_full_report(
counties=['Los Angeles', 'San Diego'],
include_pdfs=True
)
Use the unified ReportGenerator class for programmatic access:
from report_generator import ReportGenerator
# Initialize the generator
generator = ReportGenerator()
# Load data
generator.load_data(offline_mode=False) # Set to True for demo mode
# Generate complete factsheets for specific counties
results = generator.generate_full_report(
counties=['Los Angeles', 'San Diego'],
include_pdfs=True,
offline_mode=False
)
print(f"Generated {len(results['files_generated'])} files")
Two notebooks are provided for different skill levels:
notebooks/01_Quick_Start_Guide.ipynb: For beginners and non-technical usersnotebooks/02_Advanced_Usage.ipynb: For researchers and power usersLaunch Jupyter:
jupyter notebook
Then navigate to the notebooks/ folder and open the appropriate guide.
report-generator/
βββ π report_generator.py # Main unified interface (NEW)
βββ π notebooks/ # Jupyter notebooks for easy use (NEW)
β βββ 01_Quick_Start_Guide.ipynb
β βββ 02_Advanced_Usage.ipynb
βββ π main.py # Original command-line interface
βββ π flask_app.py # Main factsheet generation
βββ π data_utils.py # Data loading and processing utilities
βββ π map_utils.py # Geographic map generation
βββ π pdf_utils.py # PDF export functionality
βββ π generate_donuts.py # Population chart generation
βββ π inputs/ # Input data files
β βββ π geojson/ # Geographic boundary files
β βββ π *.csv # Statistical data files
βββ π output/ # Generated factsheets and files
βββ π templates/ # HTML templates for factsheets
βββ π static/ # CSS, fonts, and assets
βββ π tests/ # Test files
β βββ test_pdf_utils.py
β βββ test_heat_maps.py
β βββ test_air_pollution_maps.py
βββ π requirements.txt # Python dependencies
The factsheet generation follows this process:
Run the test suite to verify functionality:
# Test PDF generation
python -m unittest test_pdf_utils.py
# Test heat map generation
python -m unittest test_heat_maps.py
# Test air pollution map generation
python -m unittest test_air_pollution_maps.py
# Run all tests
python -m unittest discover -s . -p "test_*.py"
Set these for production use:
# For GitHub Pages deployment
export GITHUB_PAGES=true
# Custom data URLs
export POPULATION_DATA_URL="your-google-sheets-url"
export HEAT_DATA_URL="your-heat-data-url"
custom_config = {
'output_dir': 'custom_output',
'population_csv_url': 'your-custom-url',
'geojson_path': 'path/to/your/boundaries.geojson'
}
generator = ReportGenerator(config=custom_config)
requirements.txt)pip install -r requirements.txt
jupyter notebook notebooks/01_Quick_Start_Guide.ipynb
git checkout -b feature-namegit commit -am 'Add feature'git push origin feature-nameImport Error: Make sure all dependencies are installed:
pip install -r requirements.txt
PDF Generation Fails: Install wkhtmltopdf and geckodriver, ensure theyβre in PATH
Map Generation Errors: Verify input GeoJSON and CSV files exist and are properly formatted
Memory Issues: Process counties in smaller batches, especially for large datasets
Network Errors: Use offline_mode=True for testing without internet connectivity
This project is licensed under the MIT License - see the LICENSE file for details.
If you use this tool in research or policy work, please cite:
UCLA Latino Policy and Politics Institute. (2024). Environmental Health Factsheet Generator.
GitHub. https://github.com/ucla-lppi/report-generator
For technical support or collaboration inquiries, please contact the UCLA LPPI research team.