Chapter 4 Accessing weather data in R

4.1 Objective: To be able to demonstrate how to get TERRA REF meteorological data

This vignette shows how to read weather data for the month of January 2017 from the weather station at the University of Arizona’s Maricopa Agricultural Center into R. These data are stored online on the data management system Clowder, which is accessed using an API. More detailed information about the structure of the database and how API URLs are created is available in the weather tutorial. Data across time for one weather variable, temperature, is plotted in R. Then all eight of the weather variables have their times series plotted.

4.2 Read in data using R

A set of weather data can be accessed with a URL using the R package jsonlite. We are calling that library along with several others that will be used to clean and plot the data. The data is read in by the fromJSON function as a dataframe that also has two nested dataframes, called properties and geometries.

The geometries dataframe is then pulled out from these data, which contains the datapoints from this stream. This is combined with a transformed version of the end of the time period in the correct time zone from the stream.

The temperature data, which is five minute averages for the entire month of January 2017, is used to calculate the growing degree days for each day. Growing degree days is a measurement that is used to predict when certain plant developmental phases happen. This new dataframe will be used in the last vignette to synthesize the trait, weather, and image data.

4.3 Plot data using R

The five minute summary weather variables in the weather_data dataframe can be plotted across time, as shown below for temperature.

We can also plot the time series for all eight of the weather variables in a single figure. We first have to rearrange the data to making plotting possible using R package ggplot.

You should now be able to find, get, and use weather data from the TERRA REF project via Clowder.