airpurifyr
: Open Air Quality in R23 October 2024
All sorts of processes release particles into the air
These measurements together form “air quality”.
Has been linked with health conditions, life expectancy, mental conditions, poorer economic outcomes, global development indexes…
Typical measurements:
pm2.5
/pm5
: Particles that are 2.5/5 microns. Typically come from fires, industry, car exhausts etcso2
: Sulfur Dioxide. Typically oil refineries, diesel vehicles, coal power stationso3
: Ozone. Typically bushfires, power stations. We want ozone but not too much!no2
: Nitrogen dioxide. Typically car exhausts.co
: Carbon monoxide. Typically Wood smoke, car exhausts.…and more
So people need this. But how?
Some (in this case 61%) governments have programs to collect this data. Much of the global data is sought from citizen science projects.
OpenAQ is an environmental tech nonprofit.
Aggregate and harmonize open air quality data from across the globe onto an open-source, open-access data platform
Freely available API and data explorer
airpurifyr
brings this API into R.
httr
(will one day be ported)v2
OpenAQ API (deprecated 18 days ago 😭)API effectively works on locations and measurements
australia_measurements <- get_measurements_for_location(
country = "AU",
max_observations = 1000,
date_from = lubridate::ymd("2020-01-01"),
date_to = lubridate::ymd("2020-01-14"),
parameter = "pm25"
)
australia_measurements
# A tibble: 19,032 × 9
location_id location parameter value date_utc unit lat long
<int> <chr> <chr> <dbl> <dttm> <chr> <dbl> <dbl>
1 2487 Bathurst pm25 18.9 2020-01-14 00:00:00 µg/m³ -33.4 150.
2 2487 Bathurst pm25 19.4 2020-01-13 23:00:00 µg/m³ -33.4 150.
3 2487 Bathurst pm25 20.2 2020-01-13 22:00:00 µg/m³ -33.4 150.
4 2487 Bathurst pm25 20.9 2020-01-13 21:00:00 µg/m³ -33.4 150.
5 2487 Bathurst pm25 22.1 2020-01-13 20:00:00 µg/m³ -33.4 150.
6 2487 Bathurst pm25 23 2020-01-13 19:00:00 µg/m³ -33.4 150.
7 2487 Bathurst pm25 23.7 2020-01-13 18:00:00 µg/m³ -33.4 150.
8 2487 Bathurst pm25 24.6 2020-01-13 17:00:00 µg/m³ -33.4 150.
9 2487 Bathurst pm25 25.3 2020-01-13 16:00:00 µg/m³ -33.4 150.
10 2487 Bathurst pm25 25.8 2020-01-13 15:00:00 µg/m³ -33.4 150.
# ℹ 19,022 more rows
# ℹ 1 more variable: country <chr>
Important
You will need to aggregate this data - sensors often report times to the second and may be slightly off!
lubridate::floor_date
is great for this
locations_of_interest <- australia_measurements |>
# East coast of Australia (roughly)
dplyr::filter(long > 141, lat < -31) |>
dplyr::distinct(location) |>
dplyr::pull()
au_east_coast_2020 <- get_measurements_for_location(
country = "AU",
location = locations_of_interest,
max_observations = 10000,
date_from = lubridate::ymd("2019-12-01"),
date_to = lubridate::ymd("2020-02-01"),
parameter = "pm25"
)
High pressure \rightarrow temperature inversion \rightarrow more ozone loss
Thanh Cuong Nguyen & Arun Krishnasamy
On July 11, there was a major factory fire in Brooklyn.
Pooja Rejendran Raju & Thi My Ngoc Tran
We can check geographical coherence
Namandeep Kaur Saluja & Rowshni Farnaz Fatema
Can we pick up extra pollutants from the weekday “rush-hour” in Melbourne CBD?
airpurifyr
helps bring this into RNext steps:
v3
APIhttr2
Available at https://github.com/numbats/airpurifyr