In this section we download and preprocess data on monthly earth surface temperature anomalies, provided by the Berkeley Earth Surface Temperature Study. This study combines 1.6 billion temperature reports from 16 pre-existing archives to provide data about global and regional temperature trends. The data is put together by Berkeley Earth, and data access is granted here.
In this section we download two data sets. First, we download the
Estimated Global Land-Surface TAVG based on the Complete Berkeley
Dataset (here) and second, the Berkeley Earth analysis
for mean temperature for Germany (here). After we downloaded the files we combine the
data sets into one xts
object for further analysis.
If the data sets are not available you may download a copy of the global data set here and a copy of the data set for Germany here (both downloaded on 2022-06-14).
library(dplyr)
paste("Date of download: ", Sys.time())
## [1] "Date of download: 2023-06-16 08:40:35.562727"
### GLOBAL DATA SET ###
url_global <- "https://berkeleyearth.lbl.gov:4443/auto/Global/Complete_TAVG_complete.txt"
temp_global <- read.table(url_global, skip = 34, header = FALSE)
# In case the url is unavailable:
#temp_global<-read.table("https://userpage.fu-berlin.de/soga/data/raw-data/Complete_TAVG_complete.txt", skip = 34, header = FALSE)
header <- c(
"Year", "Month", "Monthly Anomaly",
"Monthly Unc", "Annual Anomaly",
"Annual Unc", "Five-year Anomaly",
"Five-year Unc", "Ten-year Anomaly",
"Ten-year Unc", "Twenty-year Anomaly",
"Twenty-year Unc"
)
header <- gsub(" ", "_", paste(header, "Global"))
colnames(temp_global) <- header
sample_n(temp_global, 3)
## Year_Global Month_Global Monthly_Anomaly_Global Monthly_Unc_Global
## 1 1849 7 -0.078 0.486
## 2 1772 5 -2.163 1.381
## 3 1875 6 -0.241 0.547
## Annual_Anomaly_Global Annual_Unc_Global Five-year_Anomaly_Global
## 1 -0.789 0.532 -0.661
## 2 -0.832 1.120 -0.607
## 3 -0.727 0.267 -0.378
## Five-year_Unc_Global Ten-year_Anomaly_Global Ten-year_Unc_Global
## 1 0.366 -0.646 0.308
## 2 0.776 -0.702 0.622
## 3 0.181 -0.373 0.139
## Twenty-year_Anomaly_Global Twenty-year_Unc_Global
## 1 -0.665 0.237
## 2 -0.738 0.520
## 3 -0.402 0.158
### GERMANY DATA SET ###
url_germany <- "https://berkeleyearth.lbl.gov:4443/auto/Regional/TAVG/Text/germany-TAVG-Trend.txt"
temp_germany <- read.table(url_germany, skip = 70, header = FALSE)
# In case the url is unavailable:
#temp_germany<-read.table("https://userpage.fu-berlin.de/soga/data/raw-data/germany-TAVG-Trend.txt", skip = 71, header = FALSE)
header <- c(
"Year", "Month", "Monthly Anomaly",
"Monthly Unc", "Annual Anomaly",
"Annual Unc", "Five-year Anomaly",
"Five-year Unc", "Ten-year Anomaly",
"Ten-year Unc", "Twenty-year Anomaly",
"Twenty-year Unc"
)
header <- gsub(" ", "_", paste(header, "Germany"))
colnames(temp_germany) <- header
sample_n(temp_germany, 3)
## Year_Germany Month_Germany Monthly_Anomaly_Germany Monthly_Unc_Germany
## 1 1975 6 -0.716 0.341
## 2 1935 6 1.610 0.213
## 3 1950 6 1.837 0.246
## Annual_Anomaly_Germany Annual_Unc_Germany Five-year_Anomaly_Germany
## 1 0.810 0.084 0.484
## 2 0.167 0.107 0.299
## 3 0.382 0.071 0.482
## Five-year_Unc_Germany Ten-year_Anomaly_Germany Ten-year_Unc_Germany
## 1 0.047 0.158 0.033
## 2 0.081 0.042 0.093
## 3 0.064 0.236 0.054
## Twenty-year_Anomaly_Germany Twenty-year_Unc_Germany
## 1 0.106 0.021
## 2 -0.067 0.090
## 3 0.067 0.049
Temperatures in the data sets are in Celsius and reported as anomalies relative to the January 1951 to December 1980 average. Uncertainties represent the 95% confidence interval for statistical noise and spatial undersampling effects.
Let us store the temperature anomaly variable and the corresponding
95% confidence interval in form of two different xts
class
objects, one for each data set (global and
Germany).
library(xts)
### GLOBAL DATA SET ###
dt_t_global <- as.yearmon(paste(temp_global$Year_Global,
temp_global$Month_Global,
sep = "-"
))
t_global <- xts(
temp_global[, c(
"Monthly_Anomaly_Global",
"Monthly_Unc_Global"
)],
dt_t_global
)
### GERMANY DATA SET ###
dt_t_germany <- as.yearmon(paste(temp_germany$Year_Germany,
temp_germany$Month_Germany,
sep = "-"
))
t_germany <- xts(
temp_germany[, c(
"Monthly_Anomaly_Germany",
"Monthly_Unc_Germany"
)],
dt_t_germany
)
Let us take a look at the data sets:
plot(t_global[, "Monthly_Anomaly_Global"],
main = "Monthly global Temperature anomaly",
ylab = "Temperature in °C"
)
plot(t_germany[, "Monthly_Anomaly_Germany"],
main = "Monthly temperature anomaly for Germany",
ylab = "Temperature in °C"
)
Finally, we store both data sets in a .RData
file for
further processing.
save(file = "Earth_Surface_Temperature.RData", t_germany, t_global)
Citation
The E-Learning project SOGA-R was developed at the Department of Earth Sciences by Kai Hartmann, Joachim Krois and Annette Rudolph. You can reach us via mail by soga[at]zedat.fu-berlin.de.
Please cite as follow: Hartmann, K., Krois, J., Rudolph, A. (2023): Statistics and Geodata Analysis using R (SOGA-R). Department of Earth Sciences, Freie Universitaet Berlin.