Learn R Programming

AirSensor (version 1.0.2)

pas_enhanceData: Enhance synoptic data from PurpleAir

Description

Enhance raw synoptic data from PurpleAir to create a generally useful dataframe.

Steps include:

1) Replace variable with more consistent, more human readable names.

2) Add spatial metadata for each sensor including:

  • timezone -- olson timezone

  • countryCode -- ISO 3166-1 alpha-2

  • stateCode -- ISO 3166-2 alpha-2

  • airDistrict -- CARB air districts

3) Convert data types from character to POSIXct and numeric.

4) Add distance and monitorID for the two closest PWFSL monitors

5) Add additional metadata items:

  • sensorManufacturer = "Purple Air"

  • targetPollutant = "PM"

  • technologyType = "consumer-grade"

  • communityRegion -- (where known)

Filtering by country can speed up the process of enhancement and may be performed by providing a vector ISO country codes to the countryCodes argument. By default, no subsetting is performed.

Setting outsideOnly = TRUE will return only those records marked as 'outside'.

Usage

pas_enhanceData(pas_raw = NULL, countryCodes = NULL, includePWFSL = TRUE)

Arguments

pas_raw

Dataframe returned by pas_downloadParseRawData().

countryCodes

ISO country codes used to subset the data.

includePWFSL

Logical specifying whether to calculate distances from PWFSL monitors.

Value

Enhanced Dataframe of synoptic PurpleAir data.

See Also

pas_downloadParseRawData

Examples

Run this code
# NOT RUN {
library(AirSensor)

initializeMazamaSpatialUtils()

pas <- pas_enhanceData(example_pas_raw, 'US')

setdiff(names(pas), names(example_pas_raw))
setdiff(names(example_pas_raw), names(pas))

if ( interactive() ) {
  View(pas[1:100,])
}
# }

Run the code above in your browser using DataLab