[R package] Calculation for Growing Degree Days (GDDs, ºCd)

[R package] Calculation for Growing Degree Days (GDDs, ºCd)





Growing Degree Days (GDDs) are a measure of heat accumulation used to predict crop development rates such as the growth of crops. The GDDs are calculated to provide a simple model to estimate the growth and development of plants, especially crops, based on the daily temperature.

To calculate GDDs, the base temperature for each crop should first be identified. The base temperature is the temperature below which crop growth is minimal or stops. This temperature varies by crop. For example, the base temperature for wheat is 4°C, while for corn, it’s 10°C.

This is the equation to calculate GDDs. Each day’s average temperature is accumulated by subtracting the base temperature. Typically, if the average temperature is less than the base temperature, it is considered as 0. Additionally, if the average temperature is less than zero, it is also considered as 0.

Why are GDDs Important? They help farmers and agronomists estimate when a crop will reach specific growth stages, such as flowering or maturity. Additionally, GDDs provide a way to assess the potential performance of crops under different climatic conditions. Different crops have varying base temperatures and required GDDs for maturity, so it’s crucial to use the correct values for each specific crop.






R package: gdds()

I’ve developed an R package to easily calculate GDDs.

1. Install gdds()

Let’s install the package using the code below.

if(!require(remotes)) install.packages("remotes")
if (!requireNamespace("gdds", quietly = TRUE)) {
  remotes::install_github("agronomy4future/gdds")
}
library(remotes)
library(gdds)





2. Upload the dataset for practice

Let’s upload a dataset. This is daily temperature data from the Champaign region in Illinois. I downloaded this data from NASA POWER (https://power.larc.nasa.gov/data-access-viewer/)

if(!require(readr)) install.packages("readr")
library(readr)

github="https://raw.githubusercontent.com/agronomy4future/raw_data_practice/main/Apr_15_to_Sep_12.csv"
df= data.frame(read_csv(url(github), show_col_types=FALSE))

head(df,5)
  Year  Date Day  Max   Min   Avg
1 2024 1-Jan   1 3.35 -5.13 -1.72
2 2024 2-Jan   2 2.61 -5.37 -2.12
3 2024 3-Jan   3 3.13 -3.90 -1.13
4 2024 4-Jan   4 3.94 -4.01 -0.91
5 2024 5-Jan   5 3.08 -4.11 -1.13

Let’s say I’m growing corn, which was planted on May 20, 2024, and I want to calculate GDDs for corn from planting to August 30, 2024.






3. Calculate GDDs using gdds()

The basic code for gdds() are

gdds(data, "date_col", "temp_col", "group_col", date= c("date range", "date range"), BT= 0)

As mentioned above, I want to calculate GDDs for corn from planting (May 20) to August 30, and I’ll use the following code. The base temperature for corn is 10°C.

corn_gdds= gdds(df, "Date", "Avg", date= c("2024-05-20", "2024-08-30"), BT= 10)

head(corn_gdds,5)
  Year   Date Day   Max   Min   Avg date_range adjusted_temp Days  GDDs
1 2024 20-May 141 29.02 17.80 23.45 2024-05-20         13.45    1 13.45
2 2024 21-May 142 29.56 19.31 24.58 2024-05-21         14.58    2 28.03
3 2024 22-May 143 24.74 15.28 20.09 2024-05-22         10.09    3 38.12
4 2024 23-May 144 26.77 12.47 20.44 2024-05-23         10.44    4 48.56
5 2024 24-May 145 26.78 17.51 21.96 2024-05-24         11.96    5 60.52
.
.
.

It calculates the cumulative temperature with a base temperature of 10°C.

To see this more clearly, let’s calculate GDDs in the wintertime. Suppose I’m growing winter wheat, and I want to calculate GDDs for it from Feb 20 to March 01.

wheat_gdds= gdds(df, "Date", "Avg", date= c("2024-02-20", "2024-03-01"), BT= 4)

head(wheat_gdds,5)
 Year   Date Day   Max   Min   Avg date_range adjusted_temp  Days GDDs
1 2024 20-Feb  51 12.18 -1.94  3.44 2024-02-20         0.00  1    0.00
2 2024 21-Feb  52 16.26 -0.08  8.70 2024-02-21         4.70  2    4.70
3 2024 22-Feb  53 15.59  5.43 10.87 2024-02-22         6.87  3    11.57
4 2024 23-Feb  54 11.80  1.31  6.46 2024-02-23         2.46  4    14.03
5 2024 24-Feb  55  4.08 -5.18 -0.51 2024-02-24         0.00  5    14.03
.
.
.

If the temperature is less than zero, it is considered as 0. Additionally, if the temperature is less than the base temperature (4°C), it is also considered as 0.






3.1. Calculate GDDs using gdds() with grouping.

Sometimes, temperature data has groups, and in this case, gdds() allows calculating GDDs by group.

if(!require(readr)) install.packages("readr")
library(readr)
github="https://raw.githubusercontent.com/agronomy4future/raw_data_practice/main/Apr_15_to_Sep_12_grouping.csv"
df = data.frame(read_csv(url(github), show_col_types=FALSE))

set.seed(100)
df[sample(nrow(df),7),]
    Year   Date planting_date   Max   Min   Avg
454 2024 21-Jul        May_19 26.05 16.46 21.83
4   2024  4-Jan          <NA>  3.94 -4.01 -0.91
311 2024 25-Jun         May_2 30.42 21.37 25.23
326 2024 10-Jul         May_2 27.72 14.39 21.90
98  2024  7-Apr          <NA> 15.69  3.69 10.31
391 2024 19-May        May_19 29.95 16.76 24.07
7   2024  7-Jan          <NA>  3.24 -3.87 -0.70

This dataset shows daily temperature data for different planting dates, and I want to calculate GDDs for each planting date. In this case, let’s say I’m growing industrial hemp with a base temperature of 1°C.

hemp_gdds= gdds(df, "Date", "Avg", "planting_date", date= c("2024-04-15", "2024-08-30"), BT= 1)

head(hemp_gdds,5)
  Year   Date planting_date   Max   Min   Avg date_range adjusted_temp Days  GDDs
1 2024 15-Apr        Apr_15 26.69 13.02 19.13 2024-04-15         18.13    1 18.13
2 2024 16-Apr        Apr_15 27.23 13.94 20.52 2024-04-16         19.52    2 37.65
3 2024 17-Apr        Apr_15 21.12 10.69 17.74 2024-04-17         16.74    3 54.39
4 2024 18-Apr        Apr_15 22.43  8.15 16.17 2024-04-18         15.17    4 69.56
5 2024 19-Apr        Apr_15 14.05  5.72  9.82 2024-04-19          8.82    5 78.38

GDDs for industrial hemp was calculated by each planting date. Let’s visualize this data.

if(!require(ggplot2)) install.packages("ggplot2")
library(ggplot2)

ggplot(data=hemp_gdds, aes(x=as.numeric(Days), y=GDDs, group=planting_date)) +
  geom_line(aes(color=planting_date), size=1) +
  scale_color_manual(values=c("black","red","blue")) +
  scale_x_continuous(breaks=seq(0,140,20),limits=c(0,140)) +
  scale_y_continuous(breaks=seq(0,3000,500),limits=c(0,3000)) +
  labs(x="Days from Planting", y="Growing Degree Days (°C d)", color="Planting Date") +
  theme_classic(base_size=20, base_family="serif") +
  theme(legend.position=c(0.85,0.15),
        legend.key=element_rect(color="white", fill="white"),
        legend.title=element_text(family="serif", face="plain",
                                 size=15, color= "Black"),
        legend.text=element_text(family="serif", face="plain",
                                 size=13, color= "Black"),
        legend.background=element_rect(fill= alpha(0.5)),
        axis.line=element_line(linewidth=0.5, colour="black"))
□ Github: https://github.com/agronomy4future/gdds
□ Code summary: https://github.com/agronomy4future/r_code/blob/main/Calculation_for_Growing_Degree_Days_(GDDs_%C2%BACd).ipynb






Comments are closed.