1

We have these data below in a csv file and we would like to create a polar plot from them. We are going to use this R package - openair for creating the polar plot.

    timestamp   humandate           NOppb   
1   1412877113  09/10/2014 13:51    19  
2   1412876508  09/10/2014 13:41    
3   1412876508  09/10/2014 13:41
4   1412877118  09/10/2014 13:51    17
....

However, we are missing some data for using polarPlot(),

# Load package.
library("openair")
polarPlot(dat, pollutant = "NOppb", na.rm = TRUE)

result:

Can't find the variable(s) wd ws 
Error in checkPrep(mydata, vars, type, remove.calm = FALSE) : 

It requires columns of wd and ws for wind direction and speed which we don't have.

I am told that we can pull these missing data from wunderground's api, but the problem are:

  1. how can pull the data from wunderground's api to match each row of our data above?

  2. the weather data is measured and recorded hourly as it seems but our data is not recorded hourly as you can see it above. so how is this going to match?

Any ideas what can I do?

zx8754
  • 52,746
  • 12
  • 114
  • 209
Run
  • 54,938
  • 169
  • 450
  • 748
  • 1
    I'm not familiar with wunderground, but when you have retrieved the hourly wind dataset you need (from the closest representative weather station), then round your timestamp or humandate to the nearest hour, to merge with the hourly date stamp on the weather data. – Douglas Clark Apr 29 '15 at 08:32
  • @DouglasClark thanks for the comment. do you have any example codes that I can study? Thanks. – Run Apr 29 '15 at 08:48
  • where are the NO measurements from (city) -- or where is the nearest weather station or airport? What period of time do the measurements cover? – Douglas Clark Apr 29 '15 at 10:42
  • @DouglasClark the city is London. The time period would be Jan 2014 until Jan 2015. I dunno where the nearest weather station or airport are though... – Run Apr 29 '15 at 10:47

1 Answers1

2

The openair package provides easy access to UK air quality monitoring station data, including several stations in London. These data will automatically include wind speed and direction (ws and wd). This capability is provided by openair's importAURN and importKCL functions.

Use one of these functions to download an hourly dataset from a monitoring station near your site, for the period of time you are interested in, and merge it with your data by date (timestamp). Timestamps (date column) in openair is a POSIXct date, usually to a whole hour. You will need to convert your timestamp or humandate to POSIXct using as.POSIXct, and name the resulting column date. Then round your date to the nearest whole hour, before merging on date with the AURN dataset.

Then you can make your polar plots based on the wind data, and even compare pollutant measurements to the city's own monitoring station data.

I don't know anything about specific stations in London, but read about this under importAURN and importKCL functions in the openair manual, or help in R after openair is loaded. See openair on CRAN, or the lastest updates on github (https://github.com/davidcarslaw/openair). ps: The openair author is an expert on London air quality.

Douglas Clark
  • 2,975
  • 2
  • 17
  • 20