pacu: Precision Agriculture Computational Utilities - Weather data

Weather data

Obtaining weather data

Several R packages can download weather data. Here we use the apsimx package, which provides convenient wrappers to retrieve weather data from different sources:

  • Iowa Environmental Mesonet
  • NASA-POWER (via nasapower package)
  • DayMet (via daymetr package)
  • CHIRPS (via chirps package)

For more detail on working with weather data, see the apsimx package documentation.

Using apsimx and pacu packages

Gathering and summarizing weather data

One useful way to investigate crop growing conditions is to summarize weather data and place a given season in its historical context. Let us download some weather data first.

weather.met <- pa_get_weather_sf(area.of.interest, '1990-01-01', '2020-12-31')

We can make simple plots for precipitation or temperature. A filter is used to subset years 2017 to 2020 for easier interpretation.

## Precipitation (or rain)
plot(weather.met, met.var = "rain", cumulative = TRUE, 
     climatology = TRUE, years = 2017:2020)

## Temperature
plot(weather.met, cumulative = TRUE, 
     climatology = TRUE, years = 2017:2020)

There is also a summary method for a compact display of statistics.

## Selecting just a few columns (1, 6, 7, 10) for simplicity
summary(weather.met, years = 2017:2020)[, c(1, 6, 7, 10)]
##   year avg_maxt avg_mint rain_sum
## 1 2017    15.79     3.72   814.04
## 2 2018    14.01     2.81  1401.30
## 3 2019    13.75     2.17   998.94
## 4 2020    15.47     3.11   644.34

The apsimx package does not focus on more elaborate historical summaries. In pacu, pa_plot() provides additional visualizations that help interpret crop performance data in the context of local weather history.

pa_plot(weather.met,
        plot.type = 'climate_normals', 
        unit.system = 'int')

pa_plot(weather.met,
        plot.type = 'monthly_distributions', 
        unit.system = 'int', months = 5:10)