Professional Documents
Culture Documents
DATA VISUALIZATION
SLOT: F2
THEORY DA
-BRAMHAPUTRA DATA
A) Calculate long term mean in each of grid. Map the derived result into geographical structure with
suitable color palettes.
CODE:
par(mar = c(10,10,10,10))
#par(mfrow=c(1,4))
library(ggplot2)
library(grid)
library(gridExtra)
library(extrafont)
library(ggmap)
library(maptools)
library(plyr)
library(maps)
p <- read.csv("Brahmputra_basin_data.csv")
t=dim(p)
for(i in 1:(t[2]))
total = sum(p[,i])
m <- total/(t[1]/12)
mat[i]<-m
write.csv(mat,'mean_sd.csv')
q<-read.csv("Bramhaputra_grid.csv")
chart<-list()
w <- c(746,1.55e+03,1.99e+03,2.25e+03,3.45e+03)
face = "bold"))
19BCE0761 | PARTH SHARMA
## Multiplot function
require(grid)
numPlots = length(plots)
grid.newpage()
viewport(layout.pos.row = x, layout.pos.col = y)
for (i in 1:numPlots) {
curRow = ceiling(i/plotCols)
tiff(filename = "Brahmputa_ltm.tiff", pointsize =8, res = 600, units = "in", width = 8, height = 3, restoreConsole =
TRUE, type = "cairo")
multiplot(chart[1], cols = 1)
dev.off()
19BCE0761 | PARTH SHARMA
jpeg(filename = "Brahmaputa_ltm.jpeg", pointsize =8, res = 600, units = "in", width = 8, height = 2, restoreConsole
= TRUE, type = "windows")
multiplot(chart[1], cols = 1)
dev.off()
OUTPUT:
The colours: red, green, blue and yellow are used to display the various mean of rainfall in different
regions of the Brahmaputra River.
The Red area is the part which receives the lowest rainfall whereas Yellow region receives the most
rainfall.
B) Calculate the change in average annual rainfall with respect to global warming in each grid. Then
plot the derived result.
CODE:
par(mar = c(10,10,10,10))
#par(mfrow=c(1,4))
library(ggplot2)
library(grid)
library(gridExtra)
library(extrafont)
library(ggmap)
library(maptools)
library(plyr)
library(maps)
p <- read.csv("Brahmputra_basin_data.csv")
t=dim(p)
for(i in 1:(t[2]))
sum1=0
sum2=0
for(j in 1:840){
for(k in 841:t[1]){
}
19BCE0761 | PARTH SHARMA
mat[i,1]<-avg1
avg2<- sum2/45
mat[i,2]<-avg2
write.csv(mat,'Brahma_q2_mean.csv')
q<-read.csv("Brahma_q2_grid.csv")
chart<-list()
w <- c(-14,30,60,88,185)
cols <- c("[-14,30)" = "red", "[30,60)" = "blue", "[60,88)" = "darkgreen", "[88,185)" = "darkorange")
fill="white", alpha=0)
cha <- cha+theme(text = element_text(family = "Times New Roman", size=16, face = "bold"))
## Multiplot function
require(grid)
numPlots = length(plots)
grid.newpage()
viewport(layout.pos.row = x, layout.pos.col = y)
for (i in 1:numPlots) {
curRow = ceiling(i/plotCols)
tiff(filename = "Brahmputa_q2.tiff", pointsize =8, res = 600, units = "in", width = 8, height = 5,
restoreConsole = TRUE, type = "cairo")
multiplot(chart[1], cols = 1)
dev.off()
jpeg(filename = "Brahmaputa_q2.jpeg", pointsize =8, res = 600, units = "in", width =8, height = 5,
restoreConsole = TRUE, type = "windows")
19BCE0761 | PARTH SHARMA
multiplot(chart[1], cols = 1)
dev.off()
OUTPUT:
C) Calculate the change in seasonal average rainfall with respect to global warming in each of grids.
Plot the derived results.
CODE:
par(mar = c(10,10,10,10))
#par(mfrow=c(1,4))
library(ggplot2)
library(grid)
library(gridExtra)
library(extrafont)
library(ggmap)
library(maptools)
library(plyr)
library(maps)
p <- read.csv("Brahmputra_basin_data.csv")
t=dim(p)
for(i in 1:(t[2]))
sum1=0
sum2=0
x=6
while(x<840)
for(j in x:(x+3)){
}
19BCE0761 | PARTH SHARMA
x=x+12
y=846
while(y<t[1])
for(k in y:(y+3)){
y=y+12
mat[i,1]<-avg1
avg2<- sum2/45
mat[i,2]<-avg2
write.csv(mat,'Brahma_q3_mean.csv')
q<-read.csv("Brahma_q3_grid.csv")
chart<-list()
w <- c(21,54,67,80,205)
cols <- c("[21,54)" = "red", "[54,67)" = "blue", "[67,80)" = "darkgreen", "[80,205)" = "darkorange")
cha <- cha+theme(text = element_text(family = "Times New Roman", size=16, face = "bold"))
## Multiplot function
require(grid)
numPlots = length(plots)
grid.newpage()
viewport(layout.pos.row = x, layout.pos.col = y)
for (i in 1:numPlots) {
curRow = ceiling(i/plotCols)
tiff(filename = "Brahmputa_q3.tiff", pointsize =8, res = 600, units = "in", width = 8, height = 5,
restoreConsole = TRUE, type = "cairo")
multiplot(chart[1], cols = 1)
dev.off()
jpeg(filename = "Brahmaputa_q3.jpeg", pointsize =8, res = 600, units = "in", width = 8, height = 5,
restoreConsole = TRUE, type = "windows")
multiplot(chart[1], cols = 1)
dev.off()
OUTPUT:
19BCE0761 | PARTH SHARMA
D) Calculate the average seasonal (June-Sept) rainfall in each grid for the period 1901-1920. Similarly
calculate the average seasonal (June-Sept) rainfall in each grid for the period 1990-last year. Calculate
the change in average seasonal and plot them.
CODE:
par(mar = c(10,10,10,10))
#par(mfrow=c(1,4))
library(ggplot2)
library(grid)
library(gridExtra)
library(extrafont)
library(ggmap)
library(maptools)
library(plyr)
library(maps)
p <- read.csv("Brahmputra_basin_data.csv")
t=dim(p)
for(i in 1:(t[2]))
{
19BCE0761 | PARTH SHARMA
sum1=0
sum2=0
x=6
while(x<240)
for(j in x:(x+3)){
x=x+12
y=1086
while(y<t[1])
for(k in y:(y+3)){
y=y+12
mat[i,1]<-avg1
avg2<- sum2/25
mat[i,2]<-avg2
}
19BCE0761 | PARTH SHARMA
write.csv(mat,'Brahma_q4_mean.csv')
q<-read.csv("Brahma_q4_grid.csv")
chart<-list()
w <- c(7,49,82,114,238)
cols <- c("[7,49)" = "red", "[49,82)" = "blue", "[82,114)" = "darkgreen", "[114,238)" = "darkorange")
cha <- cha+theme(text = element_text(family = "Times New Roman", size=16, face = "bold"))
## Multiplot function
require(grid)
numPlots = length(plots)
grid.newpage()
19BCE0761 | PARTH SHARMA
viewport(layout.pos.row = x, layout.pos.col = y)
for (i in 1:numPlots) {
curRow = ceiling(i/plotCols)
tiff(filename = "Brahmputa_q4.tiff", pointsize =8, res = 600, units = "in", width = 8, height = 5,
restoreConsole = TRUE, type = "cairo")
multiplot(chart[1], cols = 1)
dev.off()
jpeg(filename = "Brahmaputa_q4.jpeg", pointsize =8, res = 600, units = "in", width = 8, height = 5,
restoreConsole = TRUE, type = "windows")
multiplot(chart[1], cols = 1)
dev.off()
OUTPUT:
19BCE0761 | PARTH SHARMA
-INDIA DATA
A) Calculate long term mean in each of grid. Map the derived result into geographical structure with
suitable color palettes.
CODE:
par(mar = c(10,10,10,10))
#par(mfrow=c(1,4))
library(ggplot2)
library(grid)
library(gridExtra)
19BCE0761 | PARTH SHARMA
library(extrafont)
library(ggmap)
library(maptools)
library(plyr)
library(maps)
p <- read.csv("India_gridded_data.csv")
t=dim(p)
for(i in 1:(t[2]))
total = sum(p[,i])
m <- total/(t[1]/12)
mat[i]<-m
write.csv(mat,'India_q1_mean.csv')
q<-read.csv("India_q1_grid.csv")
chart<-list()
w <- c(62,676,978,1.32e+03,4.34e+03)
cha <- cha+theme(text = element_text(family = "Times New Roman", size=16, face = "bold"))
## Multiplot function
require(grid)
numPlots = length(plots)
of cols
grid.newpage()
viewport(layout.pos.row = x, layout.pos.col = y)
for (i in 1:numPlots) {
curRow = ceiling(i/plotCols)
tiff(filename = "India_q1.tiff", pointsize =8, res = 600, units = "in", width = 8, height = 8, restoreConsole =
TRUE, type = "cairo")
multiplot(chart[1], cols = 1)
dev.off()
jpeg(filename = "India_q1.jpeg", pointsize =8, res = 600, units = "in", width = 8, height = 8,
restoreConsole = TRUE, type = "windows")
multiplot(chart[1], cols = 1)
dev.off()
OUTPUT:
19BCE0761 | PARTH SHARMA
B) Calculate the change in average annual rainfall with respect to global warming in each grid. Then
plot the derived result.
CODE:
par(mar = c(10,10,10,10))
#par(mfrow=c(1,4))
library(ggplot2)
library(grid)
library(gridExtra)
library(extrafont)
library(ggmap)
library(maptools)
library(plyr)
library(maps)
p <- read.csv("India_gridded_data.csv")
t=dim(p)
for(i in 1:(t[2]))
sum1=0
19BCE0761 | PARTH SHARMA
sum2=0
for(j in 1:840){
for(k in 841:t[1]){
mat[i,1]<-avg1
avg2<- sum2/44
mat[i,2]<-avg2
write.csv(mat,'India_q2_mean.csv')
q<-read.csv("India_q2_grid.csv")
chart<-list()
w <- c(-215,-34,-2,67,277)
cols <- c("[-215,-34)" = "red", "[-34,-2)" = "blue", "[-2,67)" = "darkgreen", "[67,277)" = "darkorange")
fill="white", alpha=0)
cha <- cha+theme(text = element_text(family = "Times New Roman", size=16, face = "bold"))
## Multiplot function
require(grid)
numPlots = length(plots)
viewport(layout.pos.row = x, layout.pos.col = y)
for (i in 1:numPlots) {
curRow = ceiling(i/plotCols)
}
19BCE0761 | PARTH SHARMA
tiff(filename = "India_q2.tiff", pointsize =8, res = 600, units = "in", width = 8, height = 8, restoreConsole =
TRUE, type = "cairo")
multiplot(chart[1], cols = 1)
dev.off()
jpeg(filename = "India_q2.jpeg", pointsize =8, res = 600, units = "in", width = 8, height = 8,
restoreConsole = TRUE, type = "windows")
multiplot(chart[1], cols = 1)
dev.off()
OUTPUT:
19BCE0761 | PARTH SHARMA
C) Calculate the change in seasonal average rainfall with respect to global warming in each of grids.
Plot the derived results.
CODE:
par(mar = c(10,10,10,10))
#par(mfrow=c(1,4))
library(ggplot2)
library(grid)
library(gridExtra)
library(extrafont)
library(ggmap)
library(maptools)
library(plyr)
library(maps)
p <- read.csv("India_gridded_data.csv")
t=dim(p)
for(i in 1:(t[2]))
sum1=0
19BCE0761 | PARTH SHARMA
sum2=0
x=6
while(x<840)
for(j in x:(x+3)){
x=x+12
y=846
while(y<t[1])
for(k in y:(y+3)){
y=y+12
mat[i,1]<-avg1
avg2<- sum2/44
mat[i,2]<-avg2
write.csv(mat,'India_q3_mean.csv')
19BCE0761 | PARTH SHARMA
q<-read.csv("India_q3_grid.csv")
chart<-list()
w <- c(-197,-20,9,59,275)
cols <- c("[-197,-20)" = "red", "[-20,9)" = "blue", "[9,59)" = "darkgreen", "[59,275)" = "darkorange")
cha <- cha+theme(text = element_text(family = "Times New Roman", size=16, face = "bold"))
## Multiplot function
require(grid)
numPlots = length(plots)
grid.newpage()
viewport(layout.pos.row = x, layout.pos.col = y)
for (i in 1:numPlots) {
curRow = ceiling(i/plotCols)
tiff(filename = "India_q3.tiff", pointsize =8, res = 600, units = "in", width = 8, height = 8, restoreConsole =
TRUE, type = "cairo")
multiplot(chart[1], cols = 1)
dev.off()
jpeg(filename = "India_q3.jpeg", pointsize =8, res = 600, units = "in", width = 8, height = 8,
restoreConsole = TRUE, type = "windows")
multiplot(chart[1], cols = 1)
dev.off()
19BCE0761 | PARTH SHARMA
OUTPUT:
D) Calculate the average seasonal (June-Sept) rainfall in each grid for the period 1901-1920. Similarly
calculate the average seasonal (June-Sept) rainfall in each grid for the period 1990-last year. Calculate
the change in average seasonal and plot them.
CODE:
par(mar = c(10,10,10,10))
#par(mfrow=c(1,4))
19BCE0761 | PARTH SHARMA
library(ggplot2)
library(grid)
library(gridExtra)
library(extrafont)
library(ggmap)
library(maptools)
library(plyr)
library(maps)
p <- read.csv("India_gridded_data.csv")
t=dim(p)
for(i in 1:(t[2]))
sum1=0
sum2=0
x=6
while(x<240)
for(j in x:(x+3)){
}
19BCE0761 | PARTH SHARMA
x=x+12
y=1086
while(y<t[1])
for(k in y:(y+3)){
y=y+12
mat[i,1]<-avg1
avg2<- sum2/24
mat[i,2]<-avg2
write.csv(mat,'India_q4_mean.csv')
q<-read.csv("India_q4_grid.csv")chart<-list()
w <- c(-492,-48,-5,65,314)
cols <- c("[-492,-48)" = "red", "[-48,-5)" = "blue", "[-5,65)" = "darkgreen", "[65,314)" = "darkorange")
fill="white", alpha=0)
cha <- cha+theme(text = element_text(family = "Times New Roman", size=16, face = "bold"))
## Multiplot function
require(grid)
numPlots = length(plots)
viewport(layout.pos.row = x, layout.pos.col = y)
for (i in 1:numPlots) {
curRow = ceiling(i/plotCols)
}
19BCE0761 | PARTH SHARMA
tiff(filename = "India_q4.tiff", pointsize =8, res = 600, units = "in", width = 8, height = 8, restoreConsole =
TRUE, type = "cairo")
multiplot(chart[1], cols = 1)
dev.off()
jpeg(filename = "India_q4.jpeg", pointsize =8, res = 600, units = "in", width = 8, height = 8,
restoreConsole = TRUE, type = "windows")
multiplot(chart[1], cols = 1)
dev.off()
OUTPUT: