-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
71 lines (52 loc) · 1.87 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
title: "Dwd Temperature"
author: "Kmicha71"
date: "19 8 2019"
output:
html_document:
keep_md: true
pdf_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## DWD Temperature
Download the temperature data from dwd (monthly & regional summary)
```{sh downloads}
for month in "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12"
do
file="regional_averages_tm_$month.txt"
echo "Download file: $file"
[ -f ./download/$file ] && mv -f ./download/$file ./download/$file.bck
wget -q -P download https://opendata.dwd.de/climate_environment/CDC/regional_averages_DE/monthly/air_temperature_mean/$file
## Remove first line !!
tail -n +2 ./download/$file > ./download/$file.tmp && mv ./download/$file.tmp ./download/$file
done
```
```{r convert}
temp <- read.csv("./download/regional_averages_tm_01.txt", sep=";")
for (month in c("02","03","04","05","06","07","08","09","10","11","12")){
file <- paste("./download/regional_averages_tm_", month, ".txt", sep="")
print(paste("Reading file:", file))
tmp <- read.csv(file, sep=";")
temp <- rbind(temp, tmp)
}
temp <- temp[order(temp$Jahr, temp$Monat),]
names(temp)[names(temp) == "Jahr"] <- "year"
names(temp)[names(temp) == "Monat"] <- "month"
temp$ts <- signif(temp$year + (temp$month-0.5)/12, digits=6)
temp$time <- paste(temp$year,temp$month, '15 00:00:00', sep='-')
temp$X <- NULL
write.table(temp, file = "csv/monthly_temperature_de.csv", append = FALSE, quote = TRUE, sep = ",",
eol = "\n", na = "NA", dec = ".", row.names = FALSE,
col.names = TRUE, qmethod = "escape", fileEncoding = "UTF-8")
```
## Plot Temperature
```{r plot, echo=TRUE}
require("ggplot2")
temp <- read.csv("./csv/monthly_temperature_de.csv", sep=",")
mp <- ggplot() +
geom_line(aes(y=temp$Deutschland, x=temp$ts), color="blue") +
xlab("Year") + ylab("Temperature ['C]")
mp
```