Environmental analysis of crop trials using weather data Jacob van Etten Alberto Labarga
weatherDataThis package helps us to:1. Get data from weather stations2. Interpolate weather data for any location
Get the packagesinstall.packages("weatherData", repos="http://R-Forge.R-project.org")library(weatherData)install.packages(“cropData", repos="http://R-Forge.R-project.org")library(cropData)OR:http://dl.dropbox.com/u/18619554/cropData_1.0.ziphttp://dl.dropbox.com/u/18619554/weatherData_1.0.zip
Get additional packagesinstall.packages(c(“maps”, “vegan”,“reshape”))library(maps)library(vegan)library(reshape)
Get the scripthttp://dl.dropbox.com/u/18619554/maizeCA.Rhttp://goo.gl/Y6h7m
Get the dataWe will use the Global Summary of Day (GSOD)data of NCDC.ftp://ftp.ncdc.noaa.gov/pub/data/gsod/Downloading takes a lot of time.However, we can selectively download part of thedata, in an automatic way.We will show how to do it with a toy example.Then we will use data from disk to continue.
Selecting stations firstSelect stations within a geographic extentdata(stations)locsExtent <-c(0,20,40,60)stationsSelected <- stationsExtent(locsExtent, stations)Show on a mapplot(stationsSelected[c("LON","LAT")], pch=3, cex=.5)library(maps)map("world",add=TRUE, interior=F)
Download the dataMake a working directory first.setwd(“yourFolder”)Now download the files to this working directory.downloadGSOD(2010, 2010, stations = stationsSelected,silent = FALSE, tries = 2, overwrite = FALSE)After a few downloads, kill the process by pressing “Esc”.Inspect what you have in “yourFolder” and delete thedownloaded files.
Read the data into RCopy the data we have provided you into“yourFolder”.The following lines will make a table and removemissing observations.weather <- makeTableGSOD()weather <- na.omit(weather)fix(weather)
Getting some trial dataThe idea is to link weather data to crop trial data.We get some trial data that was incorporated inthe package.trial <-read.csv(system.file("external/trialsCA.csv",package="cropData"))locs <-read.csv(system.file("external/locationsCA.csv",package="cropData"))
Make a quick mapstationsSelected <- stationsExtent(c(-110,-60,5,25), stations)plot(stationsSelected[c("LON","LAT")], pch=3,cex=.5)points(locs[c("LON","LAT")], pch=15)map("world",add=TRUE, interior=F)
InterpolationWe have already seen interpolation at work.Now we use interpolation to estimate weathervariables for the trial locations.The function interpolateDailyWeather()automatically interpolates the weathersurface for each day and extracts the valuesfor each trial location.
InterpolateInterpolate weather for the years 2003, 2004 and2005.ipW2003 <- interpolateDailyWeather(tableGSOD = weatherCA,locations = locs[c("ID", "LON", "LAT", "ALT")],startDate="2003-5-15",endDate="2003-9-25",stations = stationsSelected)Repeat for the other years and then combine:ipW <- rbind(ipW2003,ipW2004,ipW2005)
Thermal stress Minimum is Duration of assumed to T > 30 °C = be at sunrise. 4.8 hTemperature (°C) Maximum is assumed to be 2 h after solar noon. Time
Derive ecophysiological vars?thermalStressDailyRun the example to see how this works.Then:TEMPSTRESS30 <- thermalStressSeasonal(30,ipW, trial, locs)PREC <- precipitationSeasonal(ipW, trial)RADIATION <- radiationSeasonal(ipW, trial, locs)trial <- cbind(trial, TEMPSTRESS30, PREC,RADIATION)
Do RDA on residualsInstead of a normal PCA, we constrain theaxes of the PCA with linear combinations ofthe ecophysiological variables.This type of constrained PCA is calledredundancy analysis (RDA)
Do ANOVAm <- lm(Yield ~ Variety + Location + Plant.m2,data=tr2005)G + GxE are left over, the rest is filtered outtr2005$Yield <- residuals(m)tr2005 <-tr2005[,c("Variety","Location","Yield")]
Putting GxE on mapIt is possible to use the resulting RDA model topredict for any locations.The steps would be:1. Interpolate weather variables for new location2. Derive ecophysiological variables3. Predict yield value for this new location (not taking into account additive environmental effect)
Final remarksTrial data are often noisy – extracting thesignal from the data is the objectiveMany environmental variables are difficult tomeasure, but can be taken to be “random” inthe analysisMany statistical tools exist to link weatherdata to crop trial data.
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.