1

I keep getting errors in my attempt to pull weather data for Detroit airport. I am able to manually go to wunderground.com to get the historical hourly data, so it does exist there for Detroit location. But R package keeps sending me errors. I used "KDTW" for the airport code but it did not work. I tried "72537" for the station ID, which I got by using getStationCode("Detroit). I will appreciate any help with getting hour historical data for any close to Detroit station for the time interval January 1, 2017 through March 28, 2017.

Here is what I tried:

 install.packages("weatherData")  
 library ('weatherData')  

getStationCode("Detroit")  
checkDataAvailabilityForDateRange(station_type ="KARB", start_date="2017-01-01", end_date="2017-03-28")  
checkDataAvailabilityForDateRange(station_id ="KDTW", start_date="2017-01-01", end_date="2017-03-28")   

Thank you!

www
  • 38,575
  • 12
  • 48
  • 84
user1656028
  • 63
  • 1
  • 4

1 Answers1

0

I was able to get the weather data for KDTW. temp <- getWeatherForDate(station_id = "KDTW", start_date = "2017-01-01", end_date="2017-01-10")

Here is my output for the date range

structure(c("Min.   :2017-01-01 00:00:00  ", "1st Qu.:2017-01-03 06:00:00  ", 
"Median :2017-01-05 12:00:00  ", "Mean   :2017-01-05 12:00:00  ", 
"3rd Qu.:2017-01-07 18:00:00  ", "Max.   :2017-01-10 00:00:00  ", 
"Min.   :17.0  ", "1st Qu.:18.5  ", "Median :34.5  ", "Mean   :31.9  ", 
"3rd Qu.:42.5  ", "Max.   :49.0  ", "Min.   :11.00  ", "1st Qu.:13.75  ", 
"Median :26.50  ", "Mean   :25.20  ", "3rd Qu.:34.25  ", "Max.   :41.00  ", 
"Min.   : 5.0  ", "1st Qu.: 9.0  ", "Median :17.5  ", "Mean   :18.2  ", 
"3rd Qu.:26.0  ", "Max.   :37.0  "), .Dim = c(6L, 4L), .Dimnames = list(
    c("", "", "", "", "", ""), c("     Date", "Max_TemperatureF", 
    "Mean_TemperatureF", "Min_TemperatureF")), class = "table")

I just got temperature data, but if you'd like, you can also get other information (like humidity, cloud cover, etc) by changing the opt_all_columns flag to TRUE.

Hope that Helps!

Edit: Looking at your code you have station_type ="KARB" Did you mean that to be station_id?

mac_staben
  • 81
  • 6
  • Thank you for the answer! I get an error with this code: Warning message: In isObtainedDataValid(wxdata, station_id, custom_url) : There seems to be no data in the URL. Try going to the URL via your browser and seeing there is data. Inspect the validity of the URL being tried: http://www.wunderground.com/history/airport/KDTW/2017/1/1/CustomHistory.html?dayend=10&monthend=1&yearend=2017&req_city=NA&req_state=NA&req_statename=NA&format=1 – user1656028 Mar 29 '17 at 20:18
  • Here's the URL that was provided: [link](https://www.wunderground.com/history/airport/KDTW/2017/1/1/CustomHistory.html?dayend=10&monthend=1&yearend=2017&req_city=NA&req_state=NA&req_statename=NA&format=1). It looked like it had data to me – mac_staben Mar 30 '17 at 16:28
  • Can you mark the question as answered, so that it shows up for anybody else who has the same problem? – mac_staben Mar 31 '17 at 15:23