View source: R/pas_downloadParseRawData.R
pas_downloadParseRawData | R Documentation |
Download and parse synoptic data for PurpleAir within the specified region.
The synoptic data provides access to data from many PurpleAir sensors at a moment in time and includes both metadata and recent PM2.5 averages for each sensor.
If show_only
is used to request specific sensors, the bounding box
information is ignored.
pas_downloadParseRawData(
api_key = NULL,
fields = SENSOR_DATA_AVG_PM25_FIELDS,
location_type = 0,
read_keys = NULL,
show_only = NULL,
modified_since = NULL,
max_age = 3600 * 24 * 7,
west = NULL,
east = NULL,
south = NULL,
north = NULL,
baseUrl = "https://api.purpleair.com/v1/sensors"
)
api_key |
PurpleAir API READ Key. If |
fields |
Character string with PurpleAir field names for the Get Sensor Data API. |
location_type |
The |
read_keys |
Optional comma separated list of sensor read_keys is required for private devices. It is separate to the api_key and each sensor has its own read_key. Submit multiple keys by separating them with a comma (,) character for example: key-one,key-two,key-three. |
show_only |
Optional comma separated list of sensor_index values. When provided, the results are limited only to the sensors included in this list. |
modified_since |
The modified_since parameter causes only sensors modified after the provided time stamp to be included in the results. Using the time_stamp value from a previous call (recommended) will limit results to those with new values since the last request. Using a value of 0 will match sensors modified at any time. |
max_age |
Number of seconds used to filter results to only include sensors
modified or updated within the |
west |
Longitude of the western edge of the bounding box in which to find sensors. |
east |
Longitude of the eastern edge of the bounding box in which to find sensors. |
south |
Latitude of the southern edge of the bounding box in which to find sensors. |
north |
Latitude of the northern edge of the bounding box in which to find sensors. |
baseUrl |
Base URL for the PurpleAir API. |
Dataframe of synoptic PurpleAir data.
# Fail gracefully if any resources are not available
try({
library(AirSensor)
initializeMazamaSpatialUtils()
pas_raw <-
pas_downloadParseRawData(
api_key = PURPLE_AIR_API_READ_KEY,
fields = SENSOR_DATA_AVG_PM25_FIELDS,
location_type = 0,
modified_since = NULL,
max_age = 3600 * 24,
west = -125,
east = -117,
south = 42,
north = 49
)
View(pas_raw[1:100,])
}, silent = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.