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:
how can pull the data from wunderground's api to match each row of our data above?
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?
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.