-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
84 lines (58 loc) · 2.36 KB
/
README.Rmd
File metadata and controls
84 lines (58 loc) · 2.36 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
---
title: "GISS Monthly Global 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)
```
## GISS Global Monthly Temperature
https://data.giss.nasa.gov/gistemp/graphs_v4/#
Download the temperature data from nasa
https://data.giss.nasa.gov/gistemp/graphs_v4/graph_data/Monthly_Mean_Global_Surface_Temperature/graph.csv
```{sh downloads}
serverName="https://data.giss.nasa.gov/gistemp/graphs_v4/graph_data/Monthly_Mean_Global_Surface_Temperature"
fileName="graph.csv"
file="giss_global_monthly.csv"
url="$serverName/$fileName"
echo "Download file: $file"
[ -f ./download/$file ] && mv -f ./download/$file ./download/$file.bck
wget -q -P download $url
## Remove first line !!
#tail -n +2 ./download/$fileName > ./download/$file.tmp && mv ./download/$file.tmp ./download/$file
cat ./download/$fileName > ./download/$file.tmp && mv ./download/$file.tmp ./download/$file
rm -f ./download/$fileName
```
```{r convert}
#Year+Month,Station,Land+Ocean,Land_Only,Open_Ocean
temp <- read.csv("./download/giss_global_monthly.csv", sep=",", skip = 1)
#temp <- temp[,c("Year","Land_Annual","Ocean_Annual")]
names(temp)[names(temp) == "Year.Month"] <- "ts"
names(temp)[names(temp) == "Land.Ocean"] <- "global"
names(temp)[names(temp) == "Land_Only"] <- "land"
names(temp)[names(temp) == "Open_Ocean"] <- "ocean"
names(temp)[names(temp) == "Station"] <- "station"
temp$year = as.integer(floor(temp$ts))
temp$month = as.integer(round((temp$ts - temp$year)*12+0.5))
temp$time <- paste(temp$year,temp$month, '15 00:00:00', sep='-')
temp <- temp[order(temp$year, temp$month),]
write.table(temp, file = "csv/monthly_temperature_global.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_global.csv", sep=",")
mp <- ggplot() +
geom_line(aes(y=temp$ocean, x=temp$ts), color="blue") +
geom_line(aes(y=temp$global, x=temp$ts), color="cyan") +
geom_line(aes(y=temp$station, x=temp$ts), color="red") +
geom_line(aes(y=temp$land, x=temp$ts), color="brown") +
xlab("Year") + ylab("Temperature ['C]")
mp
```