Journal

Hyperlocal AQI Network: Combining PurpleAir + Air4Thai API for Neighborhood-Level Bangkok PM2.5 Mapping

Hyperlocal AQI Network: รวม PurpleAir + Air4Thai API สร้าง PM2.5 Map กรุงเทพฯ ระดับชุมชน

May 12, 2026 · 2 min read
Hyperlocal AQI Network: Combining PurpleAir + Air4Thai API for Neighborhood-Level Bangkok PM2.5 Mapping

Hyperlocal AQI: Street-Level Air Quality for Your Neighborhood

Bangkok’s ~30 official PCD monitoring stations cover 1,569 km² with 5–8 km average spacing — far too coarse for neighborhood-level decisions. A Hyperlocal AQI Network aggregates PCD official stations, personal PurpleAir sensors, and OpenAQ community data to generate street-level PM2.5 maps.

Data Sources

Air4Thai API (PCD): Free public REST API providing AQI and PM2.5 from ~30 Bangkok official stations, updated hourly. PurpleAir PA-II (~5,500 THB): dual-laser optical sensor with 2-minute update interval; apply US EPA correction factor (CF=1 calibration) for accuracy. OpenAQ API: aggregates IQAir, Berkeley Earth, and community sensors with a 15km radius query around Bangkok center.

Kriging Interpolation for Continuous Maps

Ordinary Kriging (pykrige library) interpolates PM2.5 readings from discrete sensor locations onto a continuous grid (100m resolution over Bangkok). The resulting map uses a color gradient from green (<25 μg/m³) through yellow, orange, red, to purple (>150 μg/m³).

Home Assistant Dashboard

The Lovelace map-card overlays the Kriging PM2.5 raster with real-time sensor markers. Home alerts fire when the household PurpleAir sensor exceeds user-defined thresholds, with comparison to the nearest official station and Bangkok-wide average.

Practical Bangkok Applications

During January–March haze season, hyperlocal data enables: optimal outdoor exercise timing (PM2.5 daily minimum tracking), route comparison for cycling or jogging, and real-time decisions on ERV outdoor intake valve operation versus building pressurization mode.

Questions & answers

Is a PurpleAir sensor worth the cost for a home user?
PurpleAir PA-II (~5,500 THB) significantly outperforms budget sensors like SDS011 through dual-laser cross-validation and better calibration. If contributing to the public PurpleAir community map, the sensor also benefits your neighborhood.
Does the Air4Thai API require registration?
No — it is a free public endpoint requiring no API key. Query responsibly at 5–10 minute intervals to avoid overloading the PCD server infrastructure.
How does Kriging differ from simple nearest-neighbor averaging?
Kriging uses a statistical spatial correlation model (variogram) to produce physically realistic smooth interpolation. It also generates variance estimates indicating which map areas have high uncertainty — not possible with nearest-neighbor averaging.

Related reading