Temperature data is crucial for phenology and chill models, as it serves as a key input for these calculations. However, accessing weather data is often challenging due to restrictions and high costs, even when the data is publicly funded.
The chillR package facilitates access to global and California-specific weather databases, helping researchers obtain necessary temperature records.
The National Centers for Environmental Information (NCEI) provides temperature data through the GSOD database. While retrieving data manually can be cumbersome, chillR offers a streamlined solution with the function handle_gsod().
To retrieve a list of weather stations near a specific location, sorted by proximity, use:
station_list <- handle_gsod(action = "list_stations",
location = c(7.10, 50.73),
time_interval = c(1990, 2020))
This function returns a table containing station codes, available data years, and the percentage of the selected time period covered.
Once a suitable station is identified, its chillR_code can be used to download temperature records:
weather <- handle_gsod(action = "download_weather",
location = station_list$chillR_code[4],
time_interval = c(1990,2020))
This returns a list where weather[[1]] contains metadata, and weather[[2]] holds the actual temperature dataset.
Raw GSOD data contains unnecessary variables and is recorded in Fahrenheit. chillR provides a function to clean and convert these records:
cleaned_weather <- handle_gsod(weather)
Temperature values are converted using the formula:
\(Temperature[°C]=(Temperature[°F]-32)\cdot\frac{5}{9}\)
This results in a more usable dataset suitable for further analysis.
Exercises on getting temperature datahandle_gsod functionstation_list_Yakima <- handle_gsod(action = "list_stations",
location = c(long = -120.50, lat = 46.60),
time_interval = c(1990, 2020))
| chillR_code | STATION.NAME | CTRY | Lat | Long | BEGIN | END | Distance | Overlap_years | Perc_interval_covered |
|---|---|---|---|---|---|---|---|---|---|
| 72781024243 | YAKIMA AIR TERMINAL/MCALSR FIELD AP | US | 46.564 | -120.535 | 19730101 | 20250304 | 4.82 | 31.00 | 100 |
| 99999924243 | YAKIMA AIR TERMINAL | US | 46.568 | -120.543 | 19480101 | 19721231 | 4.85 | 0.00 | 0 |
| 72781399999 | VAGABOND AAF / YAKIMA TRAINING CENTER WASHINGTON USA | US | 46.667 | -120.454 | 20030617 | 20081110 | 8.25 | 5.40 | 17 |
| 72056299999 | RANGE OP 13 / YAKIMA TRAINING CENTER | US | 46.800 | -120.167 | 20080530 | 20170920 | 33.79 | 9.31 | 30 |
| 72788399999 | BOWERS FLD | US | 47.033 | -120.531 | 20000101 | 20031231 | 48.26 | 4.00 | 13 |
| 72788324220 | BOWERS FIELD AIRPORT | US | 47.034 | -120.531 | 19880106 | 20250304 | 48.37 | 31.00 | 100 |
| 99999924220 | ELLENSBURG BOWERS FI | US | 47.034 | -120.530 | 19480601 | 19550101 | 48.37 | 0.00 | 0 |
| 72784094187 | HANFORD AIRPORT | US | 46.567 | -119.600 | 20060101 | 20130326 | 68.96 | 7.23 | 23 |
| 72784099999 | HANFORD | US | 46.567 | -119.600 | 19730101 | 19971231 | 68.96 | 8.00 | 26 |
| 72782594239 | PANGBORN MEMORIAL AIRPORT | US | 47.397 | -120.201 | 20000101 | 20250304 | 91.58 | 21.00 | 68 |
| 72782599999 | PANGBORN MEM | US | 47.399 | -120.207 | 19730101 | 19971231 | 91.69 | 8.00 | 26 |
| 72788499999 | RICHLAND AIRPORT | US | 46.306 | -119.304 | 19810203 | 20250303 | 97.39 | 31.00 | 100 |
| 72781524237 | STAMPASS PASS FLTWO | US | 47.277 | -121.337 | 19730101 | 20250304 | 98.63 | 31.00 | 100 |
| 99999924237 | STAMPEDE PASS | US | 47.277 | -121.337 | 19480101 | 19721231 | 98.63 | 0.00 | 0 |
| 72790024141 | EPHRATA MUNICIPAL AIRPORT | US | 47.308 | -119.516 | 20050101 | 20250304 | 108.64 | 16.00 | 52 |
| 72782624141 | EPHRATA MUNICIPAL | US | 47.308 | -119.515 | 19420101 | 19971231 | 108.69 | 8.00 | 26 |
| 99999924141 | EPHRATA AP FCWOS | US | 47.308 | -119.515 | 19480101 | 19550101 | 108.69 | 0.00 | 0 |
| 72782724110 | GRANT COUNTY INTL AIRPORT | US | 47.193 | -119.315 | 19430610 | 20250304 | 111.73 | 31.00 | 100 |
| 72782799999 | MOSES LAKE/GRANT CO | US | 47.200 | -119.317 | 20000101 | 20031231 | 112.06 | 4.00 | 13 |
| 72784524163 | TRI-CITIES AIRPORT | US | 46.270 | -119.118 | 19730101 | 20250304 | 112.21 | 31.00 | 100 |
| 72784599999 | TRI CITIES | US | 46.267 | -119.117 | 20000101 | 20031231 | 112.40 | 4.00 | 13 |
| 99999924163 | PASCO NAS | US | 46.267 | -119.117 | 19450401 | 19460601 | 112.40 | 0.00 | 0 |
| 72698824219 | MUNICIPAL AIRPORT | US | 45.619 | -121.166 | 19730101 | 20250304 | 120.70 | 31.00 | 100 |
| 99999924219 | THE DALLES MUNICIPAL ARPT | US | 45.619 | -121.166 | 19480101 | 19650101 | 120.70 | 0.00 | 0 |
| 72688399999 | HERMISTON MUNI | US | 45.828 | -119.259 | 19980514 | 20051231 | 128.55 | 7.64 | 25 |
weather_Yakima <- handle_gsod(action = "download_weather",
location = station_list_Yakima$chillR_code[1],
time_interval = c(1990, 2020))
weather_Yakima[[1]][1:20,]
| DATE | Date | Year | Month | Day | Tmin | Tmax | Tmean | Prec | YEARMODA |
|---|---|---|---|---|---|---|---|---|---|
| 1990-01-01 12:00:00 | 1990-01-01 | 1990 | 1 | 1 | -1.722 | 1.722 | -0.500 | 0.000 | 19900101 |
| 1990-01-02 12:00:00 | 1990-01-02 | 1990 | 1 | 2 | -5.611 | 6.111 | 0.056 | 0.000 | 19900102 |
| 1990-01-03 12:00:00 | 1990-01-03 | 1990 | 1 | 3 | -5.611 | 7.778 | 0.056 | 0.000 | 19900103 |
| 1990-01-04 12:00:00 | 1990-01-04 | 1990 | 1 | 4 | -3.278 | 13.889 | 2.444 | 0.000 | 19900104 |
| 1990-01-05 12:00:00 | 1990-01-05 | 1990 | 1 | 5 | -3.278 | 13.889 | 2.556 | 0.000 | 19900105 |
| 1990-01-06 12:00:00 | 1990-01-06 | 1990 | 1 | 6 | -3.278 | 11.722 | 6.222 | 0.000 | 19900106 |
| 1990-01-07 12:00:00 | 1990-01-07 | 1990 | 1 | 7 | -2.222 | 11.722 | 9.000 | 3.048 | 19900107 |
| 1990-01-08 12:00:00 | 1990-01-08 | 1990 | 1 | 8 | 2.778 | 12.222 | 6.722 | 9.652 | 19900108 |
| 1990-01-09 12:00:00 | 1990-01-09 | 1990 | 1 | 9 | 1.111 | 11.111 | 4.111 | 15.748 | 19900109 |
| 1990-01-10 12:00:00 | 1990-01-10 | 1990 | 1 | 10 | 1.111 | 12.222 | 7.167 | 2.794 | 19900110 |
| 1990-01-11 12:00:00 | 1990-01-11 | 1990 | 1 | 11 | 0.000 | 8.278 | 2.778 | 0.000 | 19900111 |
| 1990-01-12 12:00:00 | 1990-01-12 | 1990 | 1 | 12 | 0.000 | 6.111 | 2.833 | 0.254 | 19900112 |
| 1990-01-13 12:00:00 | 1990-01-13 | 1990 | 1 | 13 | -2.778 | 6.111 | 0.944 | 0.254 | 19900113 |
| 1990-01-14 12:00:00 | 1990-01-14 | 1990 | 1 | 14 | -3.889 | 5.000 | -0.111 | 0.000 | 19900114 |
| 1990-01-15 12:00:00 | 1990-01-15 | 1990 | 1 | 15 | -3.889 | 4.389 | 0.889 | 0.000 | 19900115 |
| 1990-01-16 12:00:00 | 1990-01-16 | 1990 | 1 | 16 | -0.611 | 7.222 | 3.556 | 0.000 | 19900116 |
| 1990-01-17 12:00:00 | 1990-01-17 | 1990 | 1 | 17 | -4.389 | 7.778 | 1.111 | 0.000 | 19900117 |
| 1990-01-18 12:00:00 | 1990-01-18 | 1990 | 1 | 18 | -7.778 | 8.278 | -2.667 | 0.000 | 19900118 |
| 1990-01-19 12:00:00 | 1990-01-19 | 1990 | 1 | 19 | -7.778 | 3.278 | 0.389 | 0.000 | 19900119 |
| 1990-01-20 12:00:00 | 1990-01-20 | 1990 | 1 | 20 | -2.222 | 2.222 | 0.778 | 0.000 | 19900120 |
chillR formatcleaned_weather_Yakima <- handle_gsod(weather_Yakima)
cleaned_weather_Yakima[[1]][1:20,]
| Date | Year | Month | Day | Tmin | Tmax | Tmean | Prec |
|---|---|---|---|---|---|---|---|
| 1990-01-01 | 1990 | 1 | 1 | -1.722 | 1.722 | -0.500 | 0.000 |
| 1990-01-02 | 1990 | 1 | 2 | -5.611 | 6.111 | 0.056 | 0.000 |
| 1990-01-03 | 1990 | 1 | 3 | -5.611 | 7.778 | 0.056 | 0.000 |
| 1990-01-04 | 1990 | 1 | 4 | -3.278 | 13.889 | 2.444 | 0.000 |
| 1990-01-05 | 1990 | 1 | 5 | -3.278 | 13.889 | 2.556 | 0.000 |
| 1990-01-06 | 1990 | 1 | 6 | -3.278 | 11.722 | 6.222 | 0.000 |
| 1990-01-07 | 1990 | 1 | 7 | -2.222 | 11.722 | 9.000 | 3.048 |
| 1990-01-08 | 1990 | 1 | 8 | 2.778 | 12.222 | 6.722 | 9.652 |
| 1990-01-09 | 1990 | 1 | 9 | 1.111 | 11.111 | 4.111 | 15.748 |
| 1990-01-10 | 1990 | 1 | 10 | 1.111 | 12.222 | 7.167 | 2.794 |
| 1990-01-11 | 1990 | 1 | 11 | 0.000 | 8.278 | 2.778 | 0.000 |
| 1990-01-12 | 1990 | 1 | 12 | 0.000 | 6.111 | 2.833 | 0.254 |
| 1990-01-13 | 1990 | 1 | 13 | -2.778 | 6.111 | 0.944 | 0.254 |
| 1990-01-14 | 1990 | 1 | 14 | -3.889 | 5.000 | -0.111 | 0.000 |
| 1990-01-15 | 1990 | 1 | 15 | -3.889 | 4.389 | 0.889 | 0.000 |
| 1990-01-16 | 1990 | 1 | 16 | -0.611 | 7.222 | 3.556 | 0.000 |
| 1990-01-17 | 1990 | 1 | 17 | -4.389 | 7.778 | 1.111 | 0.000 |
| 1990-01-18 | 1990 | 1 | 18 | -7.778 | 8.278 | -2.667 | 0.000 |
| 1990-01-19 | 1990 | 1 | 19 | -7.778 | 3.278 | 0.389 | 0.000 |
| 1990-01-20 | 1990 | 1 | 20 | -2.222 | 2.222 | 0.778 | 0.000 |
dir.create("Yakima")
write.csv(station_list_Yakima,"Yakima/station_list.csv", row.names = FALSE)
write.csv(weather_Yakima[[1]],"Yakima/raw_weather.csv", row.names = FALSE)
write.csv(cleaned_weather_Yakima[[1]],"Yakima/chillR_weather.csv", row.names = FALSE)