aq_measurements | R Documentation |
Function for getting measurements table from the openAQ API
aq_measurements( country = NULL, city = NULL, location = NULL, parameter = NULL, has_geo = NULL, date_from = NULL, date_to = NULL, limit = 10000, value_from = NULL, latitude = NULL, longitude = NULL, radius = NULL, attribution = FALSE, averaging_period = FALSE, source_name = FALSE, value_to = NULL, page = NULL )
country |
Limit results by a certain country – a two-letters code see countries() for finding code based on name. |
city |
Limit results by a certain city. |
location |
Limit results by a certain location. |
parameter |
Limit to only a certain parameter (valid values are 'pm25', 'pm10', 'so2', 'no2', 'o3', 'co' and 'bc'). If no parameter is given, all parameters are retrieved. |
has_geo |
Filter out items that have or do not have geographic information. |
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. |
date_to |
Show results before a certain date. (character year-month-day, ex. '2015-12-20') |
limit |
Change the number of results returned, max is 10000 by page.
If no |
value_from |
Show results above value threshold, useful in combination with |
latitude |
Latitude of the center point (lat, lon) used to get measurements within a certain area. |
longitude |
Longitude of the center point (lat, lon) used to get measurements within a certain area. |
radius |
Radius (in meters) used to get measurements within a certain area, must be used with latitude and longitude |
attribution |
Logical, whether to add a column with attribution information |
averaging_period |
Logical, whether to add a column with averaging_period information |
source_name |
Logical, whether to add a column with source_name information |
value_to |
Show results below value threshold, useful in combination with |
page |
The page of the results to query (max 100). |
For queries involving a city or location argument, the URL-encoded name of the city/location (as in cityURL/locationURL), not its name, should be used. You can query any nested combination of country/location/city (level 1, 2 and 3), with only one value for each argument. If you write inconsistent combination such as city="Paris" and country="IN", an error message will be returned. If you write city="Delhi", you do not need to write the code of the country, unless one day there is a city with the same name in another country.
If you choose to get the attribution in the output, lines might be repeated as there might be several attributions.
A results data.frame (dplyr "tbl_df") with at least 12 columns:
the name of the location ("location"),
the parameter ("parameter")
the value of the measurement ("value")
the unit of the measure ("unit")
the code of country the location is in ("country"),
the city it is in ("city"),
and finally an URL encoded version of the city name ("cityURL")
and of the location name ("locationURL"),
the UTC POSIXct time ("dateUTC"),
the local POSIXct time ("dateLocal"),
its longitude ("longitude") and latitude if available ("latitude").
and two attributes, a meta data.frame (dplyr "tbl_df") with 1 line and 5 columns:
the API name ("name"),
the license of the data ("license"),
the website url ("website"),
the queried page ("page"),
the limit on the number of results ("limit"),
the number of results found on the platform for the query ("found")
and a timestamp data.frame (dplyr "tbl_df") with the query time and the last time at which the data was modified on the platform.
## Not run: output <- aq_measurements(country='IN', limit=9, city='Chennai', page = 1) output attr(output, "meta") attr(output, "timestamp") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.