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.
Related
I'm very new to R so I'm sorry if some of the terminology I use is incorrect. I have a large .csv file for daily visits, with the columns including the date (in D/M/Y format) and the number of visits that day in a seperate column. The date starts on 05/01/20 and ends on 06/11/20. I've plotted a daily time series of this data, and now I'm trying to plot a weekly time series, with the total sum of daily visits totaled together to get a weekly total, starting Monday and ending Sunday. I have looked through other similar questions on this site, and came across this code:
Week <- as.Date(cut(DF$Date, "week"))
aggregate(Frequency ~ Week, DF, sum)
However, I can't seem to get it to work. I would prefer to keep it as simple as possible. I also have the forecast package and zoo package installed if that helps.
I'm pretty new to R and I'm working on adding tide data to an animal movement data frame. My animal data includes a date_time column with multiple data points occurring in each day. The tide data also has multiple points per day, as tide typically changes between high and low 4 times per day. For this reason, I haven't tried to use a loop.
I'd like to create a new column in R that will classify each date/time into a "LOW" or "HIGH" category based on historical data from NOAA. So far, I've followed this: Classify date/time by tidal states
After organizing my data frames into tide2015 and rays2015, when I get to the last line of code:
Tidal.State15=tide2015$High.Low[pmax(findInterval(rays2015$Date - 3600*3, tide2015$datetime), findInterval(rays2015$Date + 3600*3, tide2015$datetime))]
I get the same error as the original post:
Error in `$<-.data.frame`(`*tmp*`, Tidal.State, value = c("L", "H", "L", : replacement has 38 rows, data has 39
I'm not sure how to get around this error. I know there are no duplicates in my data, all my dates and times are in POSIXct format, and all dates in my data are accounted for in the NOAA tide data.
Any suggestions would be greatly appreciated!
I have an excel file with station weather data. For each station, for each year (70 years), I have temperature data, as well as associated latitude and longitude of the stations. I want to create interpolated raster maps (using IDW) for each year for temperature.
My excel files are set up like this, but with 70 years of data:
I would therefore like 70 interpolated maps for each year of temperature. It also may be important to note that the stations for each year are not all the same.
I am willing to try to do this as a batch process in ArcGIS, but find that can be tedious. Is there a faster way to do this, through arcpy or even through R?
I have a daily rainfall data for 36 years. I want to analyze the time series, but my data is still in the form of frame data, how I change the frame data into time series. My data is a variable, how to unify the year number with the date and month, so the data is only in one column
You could use a time series package for that, such as fpp i.e. install.packages('fpp'). Since you don't give an example code, I can't really help you properly with it but it's quite easy.
ts(your_data, start =, frequency = ) At start = you put the year or month where you'd start and at frequency = you'd put e.g. 36 since you talk about 36 years.
You might want to check out https://robjhyndman.com/. He has an online (free) book available that walks you through the use of his package as well as providing useful information with respect to time series analysis.
Hope this helps.
I am working with remote sensing data to create time series of NDVI and Cloud cover. The data consists of 30 rows (latitude) and 40 columns (Longitude) and 212 matrix slices which are the months from 2000-03 until 2017-10. How ever R sees the data as an array and there is no date visible in the data. Except that I know that the 212 matrix are the months. How can I add a date to the matrix slices but still have the latitude and longitude to work with?
When I use:
NDVI_timeserie <- ts(name.ts.ndvi, frequency=12, start=c(2000,3))
This gives the correct time to the data but then it is not saved as date. So when I want to select only the rain season, I can't because I can't select the months and years.
I am open to suggestions and advice of creating a time series.
Thank you so much!