Complete installation and setup instructions for the Conflict Early Warning Pipeline.
- System Requirements
- Python Environment Setup
- Database Setup
- Google Earth Engine Setup
- Configuration Files
- API Keys & Credentials
- Manual Data Downloads
- Admin Boundary Configuration
- Verification
- Troubleshooting
- OS: Linux (Ubuntu 20.04+), macOS (10.15+), or Windows 10/11 with WSL2
- Python: 3.10 or 3.11 (3.12 not yet supported)
- RAM: 16GB (32GB recommended for full pipeline)
- Storage: 50GB free space (20GB for data, 30GB for database)
- PostgreSQL: Version 13 or higher
- PostGIS 3.0+
- H3 PostgreSQL (via h3-pg)
- H3-PostGIS bridge extension
- Google Earth Engine (free for research/education)
- ACLED API access (free tier available)
- IOM DTM API access (request required)
- FEWS NET Data Warehouse access
- Sentinel Hub (for Copernicus DEM)
Ubuntu/Debian:
sudo apt update
sudo apt install python3.10 python3.10-venv python3-pipmacOS (via Homebrew):
brew install python@3.10Windows: Download from python.org or use pyenv-win
cd /path/to/CEWP-CAR
python3.10 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate# Upgrade pip first
pip install --upgrade pip
# Install all requirements
pip install -r requirements.txtExpected install time: 5-10 minutes
python -c "import geopandas, h3, earthengine, xgboost; print('✓ Core dependencies installed')"Ubuntu/Debian:
sudo apt install postgresql-13 postgresql-contrib-13 postgresql-13-postgis-3
sudo apt install postgresql-13-h3 # May need to build from sourcemacOS:
brew install postgresql postgisWindows: Use EnterpriseDB installer or Docker
The H3 extension must be compiled and installed manually:
# Clone h3-pg repository
git clone https://github.com/zachasme/h3-pg.git
cd h3-pg
# Build and install
make
sudo make install
# Verify
psql -c "SELECT h3_get_version();"# Start PostgreSQL service
sudo systemctl start postgresql # Linux
brew services start postgresql # macOS
# Create database and user
sudo -u postgres psql << EOF
CREATE DATABASE car_cewp;
CREATE USER cewp_user WITH PASSWORD 'your_secure_password';
GRANT ALL PRIVILEGES ON DATABASE car_cewp TO cewp_user;
\c car_cewp
CREATE EXTENSION postgis;
CREATE EXTENSION h3;
CREATE EXTENSION h3_postgis;
EOFEdit .env file:
DB_HOST=localhost
DB_PORT=5432
DB_NAME=car_cewp
DB_USER=cewp_user
DB_PASS=your_secure_passwordpython init_db.pyExpected output:
--- STARTING DATABASE INITIALIZATION (Step 0) ---
Initializing extensions...
Extensions verified: postgis, h3, h3_postgis
✓ features_static is already compliant (BIGINT).
--- DATABASE INITIALIZATION COMPLETE ---
- Go to https://earthengine.google.com/
- Sign up using your institutional email (for research access)
- Wait for approval (usually 24-48 hours)
# The earthengine-api is already in requirements.txt
# Authenticate with your Google account
earthengine authenticate
# Follow the browser prompt to authorize
# Copy the authorization code back to terminalpython -c "import ee; ee.Initialize(); print('✓ GEE authenticated')"For automated/scheduled runs, use a service account:
- Create service account in Google Cloud Console
- Download JSON key file
- Save to
GoogleKeys/gee-service-account.json - Authenticate:
earthengine authenticate --service-account gee-service-account@project.iam.gserviceaccount.com --key-file GoogleKeys/gee-service-account.json
cp .env.example .envThe pipeline is controlled by three config files in configs/:
configs/data.yaml:
- Date ranges for data ingestion
- API endpoints and credentials
- File paths for raw data
configs/features.yaml:
- Feature engineering parameters
- H3 resolution (default: 5 ≈ 10km hexagons)
- Temporal window (default: 14 days)
- Registry of all 109 features to compute
configs/models.yaml:
- Model architectures (XGBoost, LightGBM)
- Forecast horizons (14d, 1m, 3m)
- Hyperparameters for training
Action required: Review configs/data.yaml and update:
global_date_window:
start_date: "2000-01-01" # Adjust to your needs
end_date: "2025-12-04" # Adjust to your needsCreate a .env file in the project root with the following credentials:
# --- Database ---
DB_HOST=localhost
DB_PORT=5432
DB_NAME=car_cewp
DB_USER=cewp_user
DB_PASS=your_password
# --- ACLED (Required) ---
# Register at: https://developer.acleddata.com/
ACLED_EMAIL=your_email
ACLED_KEY=your_api_key
# --- IOM DTM (Required for displacement data) ---
# Request access at: https://dtm.iom.int/data/api
IOM_PRIMARY_KEY=your_key
# --- Sentinel Hub (Required for Copernicus DEM) ---
# Register at: https://www.sentinel-hub.com/
SH_CLIENT_ID=your_client_id
SH_CLIENT_SECRET=your_client_secret
# --- FEWS NET (Required for market prices) ---
# Register at: https://fdw.fews.net/
FEWS_NET_EMAIL=your_email
FEWS_NET_PASSWORD=your_password
# --- Google Cloud (Required for BigQuery/Earth Engine) ---
# Path to your JSON service account key
GOOGLE_APPLICATION_CREDENTIALS="C:/path/to/gcp_key.json"Due to licensing restrictions and API limits, several datasets must be downloaded manually.
Ensure your project contains the following structure:
CEWP-CAR/
├── data/
│ ├── raw/
│ │ ├── acled.csv # Manual download
│ │ ├── EPR-2021.csv # Manual download
│ │ ├── wbgCAFadmin1.geojson # Manual download
│ │ └── wbgCAFadmin3.geojson # Manual download (see Section 8)
- Go to the ACLED Export Tool
- Set filters:
- Country: Central African Republic
- Event Date: 2000-01-01 to Present
- Export the file and rename it to
acled.csv - Place in
data/raw/
- Go to the ETH Zürich EPR Dataset
- Download the Core Dataset (CSV) - Version 2021
- Rename to
EPR-2021.csv - Place in
data/raw/
Note: The GeoEPR polygons are handled automatically by the pipeline's caching system, but the Core CSV is required manually.
The pipeline relies on a specific mapping between OCHA/HDX standards and World Bank standards for administrative boundaries.
| Standard | Admin 1 | Admin 2 |
|---|---|---|
| World Bank | Region | Prefecture |
| OCHA/HDX | Prefecture | Sub-prefecture |
To resolve this mismatch, perform the following file renaming:
-
Download OCHA Admin 1 (Prefectures) boundaries for CAR (GeoJSON)
- Save as:
prefectures.json
- Save as:
-
Download OCHA Admin 2 (Sub-prefectures) boundaries for CAR (GeoJSON)
- Save as:
subprefectures.json
- Save as:
Why? The pipeline's
spatial_disaggregation.pylogic looks for an "Admin 3" file to find sub-prefectures. Saving the Admin 2 file with this name bridges the gap.
Run a small test to verify everything works:
# Test with 1 year of data
python main.py \
--start-date 2023-01-01 \
--end-date 2023-12-31 \
--skip-analysis
# Expected runtime: 30-60 minutes
# Expected output: Feature matrix with ~130k rows# Verify database tables
psql -d car_cewp -c "\dt car_cewp.*"
# Should show tables:
# - features_static
# - temporal_features
# - acled_events
# - environmental_features
# - (and ~15 more)
# Verify feature matrix
ls -lh data/processed/feature_matrix.parquet
# Should be ~50-200MB depending on date rangeSolution:
pip install h3==3.7.6Solution:
# Check if PostgreSQL is running
sudo systemctl status postgresql
# Start if stopped
sudo systemctl start postgresql
# Verify port
psql -c "SHOW port;"Solution: H3 extension must be manually compiled. See Database Setup Step 2.
Solution:
# Re-authenticate
earthengine authenticate --force
# Check credentials
python -c "import ee; ee.Initialize(project='your-project-id'); print('OK')"Solution:
- Reduce date range in
configs/data.yaml - Increase system swap space
- Use a machine with more RAM (32GB recommended)
Solution:
# In WSL, PostgreSQL on Windows requires host IP
# Find Windows host IP:
ip route show | awk '/default/ {print $3}'
# Update .env:
DB_HOST=172.x.x.x # Use IP from above, not 'localhost'-
GDELT: The pipeline downloads data from the GDELT v2 Master File List (CSV/ZIP). The pipeline implements caching to minimize bandwidth.
-
Google Earth Engine: Requires an enabled GEE account linked to your Google Cloud Project.
After successful installation:
- Run full pipeline: Execute
python main.pyfor complete workflow - Explore outputs: Check
data/processed/for feature matrices and predictions - Customize: Modify
configs/*.yamlto experiment with different parameters - Usage guide: See USAGE.md for CLI examples and workflows
For questions or issues not covered here, please open an issue.