Access Air Quality Data from the 'OpenAQ' API

Provides an interface to the 'OpenAQ' API < https://openaq.org/>, a platform for real-time and historical air quality data from around the world. Users can retrieve measurement data, metadata for sensors and locations for air quality research and monitoring.


openaq R client openaq hex logo

Project Status: Active – The project has reached a stable, usable state and is being actively developed. R-CMD-check Codecov test coverage

An R package for interacting with the OpenAQ API.

Installation

CRAN (The Comprehensive R Archive Network)

openaq is available on CRAN:

install.packages("openaq")

From source

You can also install the package from source through Github. Use the pkg_install command from pak package.

install.packages("pak")

pak::pkg_install("openaq/openaq-r@*release")

Quickstart

For a full walkthrough on using openaq we recommend that you read through the “Introduction to openaq” vignette (vignette("openaq")). The following guide is a quick and minimal example to get you started.

  1. Register for an account at https://explore.openaq.org/register.
  2. Find your API key in the user account page.
  3. Save your API key as the OPENAQ_API_KEY environment variable . e.g. OPENAQ_API_KEY=yourkey in .Renviron. See help(openaq) for other ways to use and access your API key.

Now we can query OpenAQ for air quality monitoring locations. For this example we will query locations that measure PM2.5 near (with 10km) Antananarivo, Madagascar (-18.90848, 47.53751)

library(openaq)

locations <- list_locations(
    parameters_id = 2, 
    coordinates = c(latitude = -18.90848, longitude = 47.53751),
    radius = 10000
)

This returns a data frame that will look something like:

id name is_mobile is_monitor timezone countries_id country_name country_iso latitude longitude datetime_first datetime_last owner_name providers_id provider_name
41726 Antananarivo FALSE TRUE Indian/Antananarivo 182 Madagascar MG -18.90848 47.53751 2020-12-22 07:00:00 2025-01-17 20:00:00 Unknown Governmental Organization 119 AirNow

Development

Contributions are welcome. See the Development Guide for setup, building, testing, and code style. See the Contribution Guide for general contribution guidelines.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("openaq")

1.1.0 by Russ Biggs, 2 months ago


https://github.com/openaq/openaq-r, https://openaq.github.io/openaq-r/


Report a bug at https://github.com/openaq/openaq-r/issues


Browse source code at https://github.com/cran/openaq


Authors: Russ Biggs [aut, cre] , Christian Parker [aut] , Francesca Mills [ctb] , OpenAQ [cph, fnd]


Documentation:   PDF Manual  


Apache License (== 2.0) license


Imports httr2, rstudioapi, methods, lubridate

Suggests testthat, webmockr, vcr, withr, knitr, maps, rmarkdown, sf, spelling, jsonlite, mockery, webfakes


See at CRAN