Remote VIIRS fire detection at Gorongosa National Park
# Gorongosa VIIRS Fire Detection & Analysis 🛰️🔥
This repository contains a modular R pipeline for processing, analyzing, and visualizing active fire data from the **VIIRS (Visible Infrared Imaging Radiometer Suite)** sensor within the **Gorongosa National Park (GNP)** region, including the Mountain and Buffer zones.
The project has been optimized for high performance using spatial indexing and efficient point-in-polygon joins, significantly reducing processing time for multi-year datasets.
---
## Project Structure
### Analysis Scripts (Root)
- **`build_latest_dataset.R`** — The main entry point for data preparation. It combines archive and NRT data to create cached `.rds` files for specific years or the entire range.
- **`plot_fires_per_year_quarter_and_region.R`** — Generates multi-year quarterly bar plots (2017–Present) showing fire density (Fires/km²) across main regions.
- **`plot_fires_per_region_monthly.R`** — Generates monthly fire density breakdowns for a selected target year (e.g., 2025).
- **`plot_fires_stacked_per_year.R`** — Generates monthly fire density breakdowns for all years available in generated csv (i.e., 2017-2025).
- **`build_archive_cache.R`** — A utility script to force-rebuild the historical archive cache from raw CSV files.
### Modular Library (`/R/` folder)
Core logic is separated into functional modules for better maintainability:
- **`viirs_regions.R`** — Loads shapefiles and performs geometric operations to define Gorongosa National Park (*GNP*), Serra da Gorongosa (*Mountain*), and the Sustainable Development Zone (*Buffer*).
- **`viirs_summary.R`** — Contains high-performance spatial join functions to aggregate fire detections into temporal summaries.
- **`viirs_archive.R`** — Dedicated loaders for historical data.
- **`viirs_nrt.R`** — Dedicated loaders for near real-time data.
- **`viirs_combine.R`** — Handles deduplication and schema alignment when merging different VIIRS data sources.
- **`viirs_sf.R`** — Converts raw data f …