Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
prepares new version
Browse files Browse the repository at this point in the history
  • Loading branch information
maelle committed Nov 20, 2017
1 parent 9e9c6b3 commit 24e8e09
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 26 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
@@ -1,3 +1,7 @@
# ropenaq 0.2.4

* Updates documentation regarding data availability (90 days worth of data via the API).

# ropenaq 0.2.3

* Does no longer return an error if the API health status is unknown.
Expand Down
2 changes: 1 addition & 1 deletion R/measurements.R
Expand Up @@ -15,7 +15,7 @@
#' @param latitude Latitude of the center point (lat, lon) used to get measurements within a certain area.
#' @param longitude Longitude of the center point (lat, lon) used to get measurements within a certain area.
#' @param radius Radius (in meters) used to get measurements within a certain area, must be used with latitude and longitude
#' @param date_from Show results after a certain date. (character year-month-day, ex. '2015-12-20')
#' @param date_from Show results after a certain date. (character year-month-day, ex. '2015-12-20'). Note, since November 2017 the API only provides access to the last three months so if you need more data you need to fetch it via Amazon S3 (https://medium.com/@openaq/changes-to-the-openaq-api-and-how-to-access-the-full-archive-of-data-3324b136da8c), potentially using the aws.s3 package.
#' @param date_to Show results before a certain date. (character year-month-day, ex. '2015-12-20')
#' @param attribution Logical, whether to add a column with attribution information
#' @param averaging_period Logical, whether to add a column with averaging_period information
Expand Down
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -12,6 +12,8 @@ Check out [this blog post](https://ropensci.org/blog/blog/2017/02/21/ropenaq) ab

More details about the package can be found [in the vignettes](http://ropensci.github.io/ropenaq/articles/index.html), in particular the [introductory vignette](http://ropensci.github.io/ropenaq/articles/Ropenaq-vignette.html).

Via the API since November 2017 the API only provides access to the latest 90 days of OpenAQ data. The whole OpenAQ data can be accessed via Amazon S3. See [this announcement](https://medium.com/@openaq/changes-to-the-openaq-api-and-how-to-access-the-full-archive-of-data-3324b136da8c). You can interact with Amazon S3 using [the `aws.s3` package]( https://CRAN.R-project.org/package=aws.s3) and the maintainer of `ropenaq` plans to write tutorials about how to access OpenAQ data and will also keep the documentation of `ropenaq` up-to-date regarding data access changes.

# Installation

Install the package with:
Expand Down
3 changes: 0 additions & 3 deletions appveyor.yml
Expand Up @@ -20,9 +20,6 @@ environment:

- R_VERSION: patched

- R_VERSION: devel
PKGTYPE: source

GITHUB_PAT:
secure: zuFCb2IKZvA6E+eE5aSCdvaSd2Z60lgMFfJdtKGmqK67DA4l3Uz+VEPkLvrQiNam

Expand Down
4 changes: 3 additions & 1 deletion cran-comments.md
@@ -1,7 +1,7 @@
## Test environments
* local x86_64-w64-mingw32/x64 install, R 3.3.1
* Ubuntu 12.04 (on Travis CI), R devel, release and oldrel
* Windows on Appveyor CI (stable, patched and devel)
* Windows on Appveyor CI (stable, patched)

## R CMD check results

Expand All @@ -13,6 +13,8 @@

* Now waits if the API tells so.

* The documentation has been updated regarding data availability.

## Reverse dependencies

The `rnoaa` vignette using `ropenaq` can still be built.
Expand Down
2 changes: 1 addition & 1 deletion man/aq_measurements.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 9 additions & 16 deletions vignettes/Ropenaq-vignette.Rmd
Expand Up @@ -23,6 +23,10 @@ knitr::opts_chunk$set(

This R package is aimed at accessing the openaq API. OpenAQ is a community of scientists, software developers, and lovers of open environmental data who are building an open, real-time database that provides programmatic and historical access to air quality data. See their website at <https://openaq.org/> and see the API documentation at <https://docs.openaq.org/>. The package contains 5 functions that correspond to the 5 different types of query offered by the openaq API: cities, countries, latest, locations and measurements. The package uses the `dplyr` package: all output tables are data.frame (dplyr "tbl_df") objects, that can be further processed and analysed.

## What data can you get?

Via the API since November 2017 the API only provides access to the latest 90 days of OpenAQ data. The whole OpenAQ data can be accessed via Amazon S3. See [this announcement](https://medium.com/@openaq/changes-to-the-openaq-api-and-how-to-access-the-full-archive-of-data-3324b136da8c). You can interact with Amazon S3 using [the `aws.s3` package]( https://CRAN.R-project.org/package=aws.s3) and the maintainer of `ropenaq` plans to write tutorials about how to access OpenAQ data and will also keep the documentation of `ropenaq` up-to-date regarding data access changes.

# Finding measurements availability

Three functions of the package allow to get lists of available information. Measurements are obtained from *locations* that are in *cities* that are in *countries*.
Expand Down Expand Up @@ -52,7 +56,7 @@ kable(head(cities_table))
The optional `country` argument allows to do this for a given country instead of the whole world.
```{r, cache=FALSE}
cities_tableIndia <- aq_cities(country="IN", limit = 10)
cities_tableIndia <- aq_cities(country="IN", limit = 10, page = 1)
kable(cities_tableIndia)
```
Expand Down Expand Up @@ -83,24 +87,16 @@ Two functions allow to get data: `aq_measurement` and `aq_latest`. In both of th
The `aq_measurements` function has many arguments for getting a query specific to, say, a given parameter in a given location or for a given circle outside a central point by the use of the `latitude`, `longitude` and `radius` arguments. Below we get the PM2.5 measures for Delhi in India.
```{r, cache=FALSE}
results_table <- aq_measurements(country = "IN", city = "Delhi", parameter = "pm25")
kable(head(results_table))
results_table <- aq_measurements(country = "IN", city = "Delhi", parameter = "pm25", limit = 10, page = 1)
kable(results_table)
```
One could also get all possible parameters in the same table.
## The `aq_latest` function
This function gives a table with all newest measures for the locations that are chosen by the arguments. If all arguments are `NULL`, it gives all the newest measures for all locations.
```{r, cache=FALSE}
tableLatest <- aq_latest()
kable(head(tableLatest))
```
Below are the latest values for Hyderabad at the time this vignette was compiled.
This function gives a table with all newest measures for the locations that are chosen by the arguments. If all arguments are `NULL`, it gives all the newest measures for all locations. Below are the latest values for Hyderabad at the time this vignette was compiled.
```{r, cache=FALSE}
tableLatest <- aq_latest(country="IN", city="Hyderabad")
Expand All @@ -113,12 +109,9 @@ For all endpoints/functions, there a a `limit` and a `page` arguments, which ind
```{r, eval = FALSE}
aq_measurements(city = "Delhi",
parameter = "pm25")
aq_measurements(city = "Delhi", parameter = "pm25")
```
If you really need a lot of data, maybe using the API and this package is not the best choice for you. You can look into downloading csv data from OpenAQ website, e.g. [here](https://openaq.org/#/locations?_k=jk7d09) or the daily csv output [here](http://openaq-data.s3.amazonaws.com/index.html). Or you might want to contact OpenAQ.
# Rate limiting
In October 2017 the API introduced a rate limit of 2,000 requests every 5 minutes. Please keep this in mind. In the case when the request receives a response status of 429 (too many requests), the package will wait 5 minutes.
Expand Down
9 changes: 5 additions & 4 deletions vignettes/using_openair_package_with_openaq_data.Rmd
Expand Up @@ -32,8 +32,8 @@ library("dplyr")

```{r}
measurementsNL <- aq_measurements(location="Amsterdam-Einsteinweg", parameter="pm25",
date_from="2015-09-01",
date_to="2015-12-31")
date_from = as.character(Sys.Date() - 100),
date_to = as.character(Sys.Date()))
# filter negative values
# and rename columns for compatibilities with openair
Expand All @@ -51,15 +51,16 @@ measurementsNL <- as.data.frame(measurementsNL)

```{r, fig.width=7, fig.height=4}
# useful timeplot
timePlot(mydata=measurementsNL, pollutant = "pm25")
timePlot(mydata = measurementsNL, pollutant = "pm25")
```

# Calendarplot

```{r, fig.width=7, fig.height=4}
# cool calendar plot
calendarPlot(mydata=measurementsNL, pollutant = "pm25", year =2015)
calendarPlot(mydata=measurementsNL, pollutant = "pm25",
year = as.numeric(format(Sys.Date(), "%Y")))
```

0 comments on commit 24e8e09

Please sign in to comment.