This is a rudimentary script that pulls the latest AQI data from AirNow.gov.
This script expects that you're in a Python environment (we use Anaconda) and have csvkit
installed.
git clone git@github.com:nprapps/aqi-process.git
cd aqi-process
conda create --name aqi-process python=3.9
conda install -c conda-forge csvkit
To run it:
conda activate aqi-process
bash aqi.sh
The AQI datafile is a pipe-delimited .dat
textfile, updated hourly. Documentation lives here.
Note: Forecast data beyond the current day does not exist for all reporting areas.
Additional data and documentation (API account may be required to access)
- Download the datafile from the AQI site
- Add column headers
- Convert to a CSV and trim out extra columns / rows
- Query results just for a subset of cities
- Export the filtered set to JSON and copy it over to a dgnext graphic
aqi-cities-20230608
in the separategraphics-js
repo- (Assumption: you work at NPR and already have this repo on your machine.)
TODO: Perhaps borrowing from the covid data pipeline, upload this to a server and set it on a cron, uploading the result to a folder on apps.npr.org.