pat_downloadParseRawData: Download time series data from PurpleAir

View source: R/pat_downloadParseRawData.R

pat_downloadParseRawDataR Documentation

Download time series data from PurpleAir

Description

Download and parse time series data for a specific sensor_index.

Usage

pat_downloadParseRawData(
  api_key = NULL,
  sensor_index = NULL,
  startdate = NULL,
  enddate = NULL,
  timezone = "UTC",
  average = 0,
  fields = AIRSENSOR_1_PAT_FIELDS,
  baseUrl = "https://api.purpleair.com/v1/sensors"
)

Arguments

api_key

PurpleAir API Read Key. If api_key = NULL, it will be obtained using getAPIKey("PurpleAir-read"). See MazamaCoreUtils::setAPIKey.

sensor_index

PurpleAir sensor unique identifier.

startdate

Desired start datetime (ISO 8601).

enddate

Desired end datetime (ISO 8601).

timezone

Olson timezone used to interpret dates.

average

Temporal averaging in minutes performed by PurpleAir. One of: 0 (raw), 10, 30, 60 (hour), 360, 1440 (day).

fields

Character string with PurpleAir field names for the Get Sensor Data API.

baseUrl

Base URL for the PurpleAir API.

Value

Dataframe of time series PurpleAir data.

References

PurpleAir

PurpleAir API

PurpleAir Terms of service

PurpleAir Data license

PurpleAir Data Attribution

Examples


# Fail gracefully if any resources are not available
try({

library(AirSensor)

initializeMazamaSpatialUtils()

pat_raw <-
  pat_downloadParseRawData(
    api_key = PURPLE_AIR_API_READ_KEY,
    sensor_index = "2323",
    startdate = "2023-02-01",
    enddate = "2023-02-02",
    timezone = "UTC"
  )

View(pat_raw[1:100,])

}, silent = FALSE)


MazamaScience/AirSensor documentation built on April 28, 2023, 11:16 a.m.