-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.R
471 lines (437 loc) · 21.1 KB
/
app.R
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
##########################################################################################################################################################################################################################
# Title : Tracking and Analyzing the Spatial Temporal Variation of Australian Bushfire 2019-2020 Using MODIS and VIIRS Data
#
# Purpose : This Script is written as a final project for the Graphic Course 04-GEO-SOS1 (http://eagle-science.org/project/scientific-graphics/)
#
# Author : Walid Ghariani (linkedin: https://www.linkedin.com/in/walid-ghariani-893365138/) (E-mail: walid.ghariani@stud-mail.uni-wuerzburg.de | walid11ghariani@gmail.com)
#
# Input : csv data from diffrent Instrument/Satellites (MODIS C6/Terra-Aqua; VIIRS/S-NPP ; VIIRS/NOAA 20)
#
# Processing : Arrange the data, Create Functions and Deploy the R shiny app
#
# Output : Australian Bushfire 2019-2020 R Shiny App
##########################################################################################################################################################################################################################
list.of.packages <- c("ggplot2", "dplyr", "plyr", "tidyquant",
"shiny","shinydashboard","shinycssloaders","leaflet","leaflet.extras")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[, "Package"])]
if (length(new.packages)) {
print("installing : ")
print(new.packages)
install.packages(new.packages, repos = "http://cran.rstudio.com/", dependencies = TRUE)
}
library(shiny)
library(shinydashboard)
library(leaflet)
library(shinycssloaders)
library(leaflet.extras)
library(dplyr)
library(plyr)
library(ggplot2)
library(plotly)
library(tidyquant)
library(xts)
###############################################################################
## Read the data from the diffrent Instrument/Satellites
# MODIS C6/Terra-Aqua
df_modis <- read.csv("./www/fire_archive_M6_155743.csv")
MODIS_C6<- df_modis %>%
select(longitude, latitude,acq_date,frp,brightness) %>%
mutate(acq_Date = as.Date(acq_date),
acq_month = months(as.POSIXlt(acq_Date)),
acq_day = day(as.POSIXlt(acq_Date)),
brightness= brightness - 273.15) %>%
filter(brightness>0)
# VIIRS/S-NPP
df1_VIIRS <- read.csv("./www/fire_archive_V1_155745.csv")
VIIRS_SNPP<- df1_VIIRS %>%
select(longitude, latitude,acq_date,frp,bright_ti4) %>%
mutate(acq_Date = as.Date(acq_date),
acq_month = months(as.POSIXlt(acq_Date)),
acq_day = day(as.POSIXlt(acq_Date)),
brightness= bright_ti4 - 273.15) %>%
filter(bright_ti4>0)
# VIIRS/NOAA 20
df2_VIIRS <- read.csv("./www/fire_nrt_J1V-C2_155744.csv")
VIIRS_NOAA_20<- df2_VIIRS%>%
select(longitude, latitude,acq_date,frp,brightness) %>%
mutate(acq_Date = as.Date(acq_date),
acq_month = months(as.POSIXlt(acq_Date)),
acq_day = day(as.POSIXlt(acq_Date)),
brightness= brightness - 273.15) %>%
filter(brightness>0)
## Important note:> The data provided by VIIRS_NOAA_20 didn't recorded the data from Sept. to Dec. of 2019
### II. Functions to VIZ the Fire Radiation Power 'FRP' and The brightness Temperature 'BT' from different satellites
# create a color Bins for FRP & BT
bins_FRP <- c(0,5, 10, 20,30,40,50,60,Inf)
bins_BT <- c(0,10, 20, 30,40,50,60,70,80,Inf)
# Create a col pal. for each variable: FRP & BT
pal_FRP <- colorBin("Reds", domain =MODIS_C6$frp , bins = bins_FRP)
pal_BT <- colorBin("YlOrRd", domain =MODIS_C6$brightness , bins = bins_BT)
# Create a label function
label_FRP <- function(Sat){
sprintf(
"<strong>%s</strong><br/>%g (MW)",
'FRP',Sat$frp
) %>%
lapply(htmltools::HTML)
}
label_BT <- function(Sat){
sprintf(
"<strong>%s</strong><br/>%g (c\u00B0)",
'BT',Sat$brightness
) %>%
lapply(htmltools::HTML)
}
# Data_VIZ function to minimize the code while using different Satellites data
Data_VIZ<-function(Sat,Var,pal,label){
VIZ_1<-leaflet(Sat) %>%
addTiles(group = "OSM (default)") %>%
addProviderTiles(providers$CartoDB.DarkMatter, group = "CartoDB.DM") %>%
addCircleMarkers(lng = ~longitude,
lat = ~latitude,
col = ~pal(Var),
opacity = 0.9,
label = label,#~as.character(paste0("FRP(MW): ", sep = " ", frp)),
radius = 1,
fillOpacity = 0.5,
labelOptions = labelOptions(style = list("font-weight" = "normal",
padding = "3px 8px"),
textsize = "15px",direction = "auto")) %>%
setView( 134.22436681269832, -27.031126703266906, 3.5 ) %>%
addMiniMap(position = "bottomleft", width = 120, height = 120) %>% # Layers control
addLayersControl(
baseGroups = c("CartoDB.DM","OSM (default)"),
options = layersControlOptions(collapsed = FALSE))
if (Var == Sat$frp){
return(VIZ_1 %>%
leaflet::addLegend(pal = pal, values = ~Var, position = "bottomright",title = 'FRP (MW)'))
}
else (
return(VIZ_1 %>%
leaflet::addLegend(pal = pal, values = ~Var, position = "bottomright",title = 'BT (c\u00B0)')
)
)
}
### Function for VIZ Heat map according to the Instrument/satellite
Data_HM<-function(Sat){
leaflet(Sat) %>%
addTiles(group = "OSM (default)") %>%
addProviderTiles(providers$CartoDB.DarkMatter, group = "CartoDB.DM") %>%
addHeatmap(lng = ~longitude,
lat = ~latitude,
intensity = ~brightness,
blur = 16, max = 0.05, radius = 10,
minOpacity = 0.05)%>%
setView( 134.22436681269832, -27.031126703266906, 3.5 ) %>%
addMiniMap(position = "bottomleft", width = 120, height = 120) %>%
addLayersControl(
baseGroups = c("CartoDB.DM","OSM (default)"),
options = layersControlOptions(collapsed = FALSE))
}
### Create a Function to arrange the data and to VIZ Time-Series Calendar Heatmap: of the The daily The daily Mean FRP and the daily maen BT
# Create a Function to arrange the data
Sat_TS<-function(Sat){
Sat%>%
dplyr::group_by(acq_Date) %>%
dplyr::summarise(Mean_FRP = mean(frp),
mean_BT = mean(brightness),
across(c(mean_BT, Mean_FRP), ~ round(., 3)),
.groups = 'drop')%>%
mutate(
# new$weekday = as.POSIXlt(new$date_form)$wday #finding the day no. of the week
weekday = as.POSIXlt(acq_Date)$wday,
# converting the day no. to factor
Day = factor(weekday,levels=rev(0:6),labels=rev(c("Mon","Tue","Wed","Thu","Fri","Sat","Sun")),ordered=TRUE),
# finding the month
Month = factor(month(acq_Date),levels=as.character(1:12),labels=c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),ordered=TRUE),
# finding the year and the month from the date.
yearmonth = factor(as.yearmon(acq_Date)),
# finding the week of the year for each date
week = as.numeric(format(acq_Date,"%W"))
) %>%
plyr::ddply(.(yearmonth),transform,Week_Month=1+week-min(week))
}
# Call the different Satellites data
MODIS_C6_TS <- Sat_TS(MODIS_C6)
VIIRS_SNPP_TS<-Sat_TS(VIIRS_SNPP)
VIIRS_NOAA_20_TS <- Sat_TS(VIIRS_NOAA_20)
# Function to VIZ Time-Series Calendar Heatmap:
viz_TS <- function(Sat_VIZ, Var){
VIZ_2 <- ggplot(Sat_VIZ, aes(Week_Month, Day, fill = Var)) +
geom_tile(colour = "white") + facet_grid(year(Sat_VIZ$acq_Date)~Month) +
labs(x="Week of Month", y = "", caption = "Data source: https://firms.modaps.eosdis.nasa.gov")+
theme(plot.title = element_text(face="bold"),
axis.title.x = element_text(size=14, face = "bold"),
plot.caption = element_text(face = "italic",size=10),
legend.position="bottom")
if (Var == Sat_VIZ$Mean_FRP){
return(VIZ_2+
scale_fill_gradient(low="#FFFFFF", high="#FF0000")+
ggtitle("Time Series Calendar Heatmap:\nThe daily Mean Fire Radiative Power (MW)")+
labs(fill = "FPR (MW)"))
}
else (
return(VIZ_2+
scale_fill_gradient(low="#FFFF80", high="#FF0000")+
ggtitle("Time Series Calendar Heatmap:\nThe daily Mean Brightness Temperature (c\u00B0)")+
labs(fill = " BT (c\u00B0)"))
)
}
# Function to VIZ Time Series variation of the varibales with a scatter plot foramts
viz_SP<- function(Sat_sp, Var_sp){
VIZ_3 <- ggplot(Sat_sp,aes(acq_Date, Var_sp))+
scale_x_date(date_labels = "%m-%Y",date_minor_breaks = "1 month")+
labs(x = "Date",caption = "Data source: https://firms.modaps.eosdis.nasa.gov")+
theme(plot.title = element_text(face="bold", size = 16, hjust = 0.5),
axis.title.x = element_text(size=12),
axis.title.y = element_text(size=12),
plot.caption = element_text(face = "italic"))+
expand_limits(y = 0)
if (Var_sp == Sat_sp$Mean_FRP){
return(VIZ_3+
geom_point(colour="#ef3b2c")+
geom_line(colour="#ef3b2c")+
ggtitle("Time Series of The daily Mean Fire Radiative Power (MW)")+
ylab("Mean Fire Radiative Power (MW)"))
}
else (
return(VIZ_3+
geom_point(colour="#fd8d3c")+
geom_line(colour="#fd8d3c")+
ggtitle("Time Series of The daily Mean Brightness Temperature (c\u00B0)")+
ylab("Mean Brightness Temperature (c\u00B0)"))
)
}
############################ User Interface
ui <-
dashboardPage(
dashboardHeader(title = "Australian Bushfire (Sep. 2019 - Mar. 2020)",
disable = FALSE,
titleWidth = 480),
dashboardSidebar(tags$style(type="text/css",".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"),
width = 300,
sidebarMenu(id="tabs",
menuItem("Tracking The Bushfires", tabName="Maps", icon=icon("map-marked-alt")),
menuItem("Time Series Analysis", tabName = "TSA",icon = icon("line-chart")),
menuItem("Call For Action", tabName = "wwf", icon = icon("fire")),
menuItem("ReadMe", tabName = "readme", icon=icon("mortar-board")),
menuItem("About", tabName = "about", icon = icon("question"))
)
),
dashboardBody(
tabItems(
tabItem(tabName = "Maps",
fluidPage(
fluidRow(
box(title = "Settings",solidHeader = TRUE,collapsible = TRUE,status = "primary",background = "black",width =4,height = 600,
selectInput(inputId = "selected_Month",
label = "Select Month:",
choices = unique(MODIS_C6$acq_month)),
sliderInput(inputId = "selected_Day", "Select Day:",
min = 1, max =31, value = 1),
radioButtons(inputId = "SAT", label = "Select Instrument/Satellite",
c("MODIS C6/Terra-Aqua"= "MODIS",
"VIIRS/S-NPP"= "VIIRS_SNPP",
"VIIRS/NOAA 20"= "VIIRS_NOAA")),
radioButtons(inputId = "VAR", label = "Select Variable",
c("Fire Radiative Power" = "FRP_1",
"Brightness Temperature" = "BT_1",
"Heat Map" = "HM"))
),
box(title = "Interactive Map", solidHeader = TRUE, collapsible = TRUE,status = "warning",background = "black",width =8,height = 600,
leafletOutput(outputId = "IM",height = "540px") %>%
withSpinner(color="#ffba00")
)
)
)
),
tabItem(tabName = "TSA",
fluidPage(
fluidRow(
box( title = "Settings",solidHeader = TRUE,collapsible = TRUE,status = "primary",background = "black",width =4,height = 600,
radioButtons(inputId = "inst_sat", label = "Select Instrument/Satellite",
c("MODIS C6/Terra-Aqua"= "MODIS",
"VIIRS/S-NPP"= "VIIRS_SNPP",
"VIIRS/NOAA 20"= "VIIRS_NOAA")),
radioButtons(inputId = "Variable", label = "Select Variable",
c("Fire Radiative Power" = "FRP_2",
"Brightness Temperature" = "BT_2")),
radioButtons(inputId = "plot", label = "Select Plot Format",
c("Calendar Heat Map" = "CHM"
,"Scatter Plot" = "SP")),
downloadButton('download', 'Download')
),
box(title = "Plot",status = "warning",solidHeader = TRUE,collapsible = TRUE,background = "black",width =8,height = 600,
plotOutput(outputId="TSA_1",height="400px") %>%
withSpinner(color="#ffba00"))
)
)
),
tabItem(tabName = "readme",
fluidPage(
tags$iframe(src = './readme.html',
width = '100%', height = '800px',
frameborder = 0, scrolling = 'auto'
)
)
),
tabItem(tabName = "about",
fluidPage(
tags$iframe(src = './about.html',
width = '100%', height = '800px',
frameborder = 0, scrolling = 'auto')
)
),
tabItem(tabName = "wwf",
HTML('<iframe width="1100" height="600" src="https://www.youtube.com/embed/Uq9bcIvdYNk" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>')
)
)
)
)
############################ Server Interface
server <- function(input, output) {
# suppress warnings
storeWarn<- getOption("warn")
options(warn = -1)
output$IM <- renderLeaflet({
# Function to choose one of the Inst./inst_sat. data frame since they share the same periode of time
inst_sat_option <- function(inst_inst_sat){
inst_inst_sat %>%
filter(acq_month ==input$selected_Month & acq_day == input$selected_Day)
}
Modis_c6 <- inst_sat_option(MODIS_C6)
Viirs_SNPP <- inst_sat_option(VIIRS_SNPP)
Viirs_NOAA <- inst_sat_option(VIIRS_NOAA_20)
# Funciotn to VIZ the data according to the input
if(input$VAR == "FRP_1" & input$SAT == "MODIS" ){
Data_VIZ(Modis_c6 , Modis_c6$frp, pal_FRP, label_FRP(Modis_c6))
}
else if (input$VAR == "FRP_1" & input$SAT == "VIIRS_SNPP"){
Data_VIZ(Viirs_SNPP , Viirs_SNPP$frp, pal_FRP, label_FRP(Viirs_SNPP))
}
else if (input$VAR == "FRP_1" & input$SAT == "VIIRS_NOAA"){
Data_VIZ(Viirs_NOAA , Viirs_NOAA$frp, pal_FRP, label_FRP(Viirs_NOAA))
}
#
else if (input$VAR == "BT_1" & input$SAT == "MODIS"){
Data_VIZ(Modis_c6 , Modis_c6$brightness, pal_BT, label_BT(Modis_c6))
}
else if (input$VAR == "BT_1" & input$SAT == "VIIRS_SNPP"){
Data_VIZ(Viirs_SNPP , Viirs_SNPP$brightness, pal_BT, label_BT(Viirs_SNPP))
}
else if (input$VAR == "BT_1" & input$SAT == "VIIRS_NOAA"){
Data_VIZ(Viirs_NOAA , Viirs_NOAA$brightness, pal_BT, label_BT(Viirs_NOAA))
}
#
else if (input$VAR == "HM" & input$SAT == "MODIS"){
Data_HM(Modis_c6)
}
else if (input$VAR == "HM" & input$SAT == "VIIRS_SNPP"){
Data_HM(Viirs_SNPP)
}
else if (input$VAR == "HM" & input$SAT == "VIIRS_NOAA"){
Data_HM(Viirs_NOAA)
}
})
output$TSA_1 <- renderPlot({
# Time-Series Analysis with a Calendar Heatmap format
if (input$Variable == "FRP_2" & input$inst_sat == "MODIS" & input$plot == "CHM"){
viz_TS(MODIS_C6_TS,MODIS_C6_TS$Mean_FRP)
}
else if (input$Variable == "FRP_2" & input$inst_sat == "VIIRS_SNPP" & input$plot == "CHM"){
viz_TS(VIIRS_SNPP_TS,VIIRS_SNPP_TS$Mean_FRP)
}
else if (input$Variable == "FRP_2" & input$inst_sat == "VIIRS_NOAA" & input$plot == "CHM"){
viz_TS(VIIRS_NOAA_20_TS, VIIRS_NOAA_20_TS$Mean_FRP)
}
#
else if (input$Variable == "BT_2" & input$inst_sat == "MODIS" & input$plot == "CHM"){
viz_TS(MODIS_C6_TS, MODIS_C6_TS$mean_BT)
}
else if (input$Variable == "BT_2" & input$inst_sat == "VIIRS_SNPP" & input$plot == "CHM"){
viz_TS(VIIRS_SNPP_TS, VIIRS_SNPP_TS$mean_BT)
}
else if (input$Variable == "BT_2" & input$inst_sat == "VIIRS_NOAA" & input$plot == "CHM"){
viz_TS(VIIRS_NOAA_20_TS, VIIRS_NOAA_20_TS$mean_BT)
}
# Time-Series Analysis with a Scatter plot format
else if (input$Variable == "FRP_2" & input$inst_sat == "MODIS" & input$plot == "SP"){
viz_SP(MODIS_C6_TS,MODIS_C6_TS$Mean_FRP)
}
else if (input$Variable == "FRP_2" & input$inst_sat == "VIIRS_SNPP" & input$plot == "SP"){
viz_SP(VIIRS_SNPP_TS,VIIRS_SNPP_TS$Mean_FRP)
}
else if (input$Variable == "FRP_2" & input$inst_sat == "VIIRS_NOAA" & input$plot == "SP"){
viz_SP(VIIRS_NOAA_20_TS, VIIRS_NOAA_20_TS$Mean_FRP)
}
#
else if (input$Variable == "BT_2" & input$inst_sat == "MODIS" & input$plot == "SP"){
viz_SP(MODIS_C6_TS, MODIS_C6_TS$mean_BT)
}
else if (input$Variable == "BT_2" & input$inst_sat == "VIIRS_SNPP" & input$plot == "SP"){
viz_SP(VIIRS_SNPP_TS, VIIRS_SNPP_TS$mean_BT)
}
else if (input$Variable == "BT_2" & input$inst_sat == "VIIRS_NOAA" & input$plot == "SP"){
viz_SP(VIIRS_NOAA_20_TS, VIIRS_NOAA_20_TS$mean_BT)
}
}, height=540)
#download files
output$download <- downloadHandler(
filename = function() {paste("Australian Bushfire", '.pdf', sep='') },
content = function(file) {
# Time-Series Analysis with a Calendar Heatmap format
if (input$Variable == "FRP_2" & input$inst_sat == "MODIS" & input$plot == "CHM"){
viz_TS(MODIS_C6_TS,MODIS_C6_TS$Mean_FRP)
ggsave(file, plot = viz_TS(MODIS_C6_TS,MODIS_C6_TS$Mean_FRP), device = "pdf")
}
else if (input$Variable == "FRP_2" & input$inst_sat == "VIIRS_SNPP" & input$plot == "CHM"){
viz_TS(VIIRS_SNPP_TS,VIIRS_SNPP_TS$Mean_FRP)
ggsave(file, plot = viz_TS(VIIRS_SNPP_TS,VIIRS_SNPP_TS$Mean_FRP), device = "pdf")
}
else if (input$Variable == "FRP_2" & input$inst_sat == "VIIRS_NOAA" & input$plot == "CHM"){
viz_TS(VIIRS_NOAA_20_TS, VIIRS_NOAA_20_TS$Mean_FRP)
ggsave(file, plot = viz_TS(VIIRS_NOAA_20_TS, VIIRS_NOAA_20_TS$Mean_FRP), device = "pdf")
}
#
else if (input$Variable == "BT_2" & input$inst_sat == "MODIS" & input$plot == "CHM"){
viz_TS(MODIS_C6_TS, MODIS_C6_TS$mean_BT)
ggsave(file, plot = viz_TS(MODIS_C6_TS, MODIS_C6_TS$mean_BT), device = "pdf")
}
else if (input$Variable == "BT_2" & input$inst_sat == "VIIRS_SNPP" & input$plot == "CHM"){
viz_TS(VIIRS_SNPP_TS, VIIRS_SNPP_TS$mean_BT)
ggsave(file, plot = viz_TS(VIIRS_SNPP_TS, VIIRS_SNPP_TS$mean_BT) , device = "pdf")
}
else if (input$Variable == "BT_2" & input$inst_sat == "VIIRS_NOAA" & input$plot == "CHM"){
viz_TS(VIIRS_NOAA_20_TS, VIIRS_NOAA_20_TS$mean_BT)
ggsave(file, plot = viz_TS(VIIRS_NOAA_20_TS, VIIRS_NOAA_20_TS$mean_BT) , device = "pdf")
}
# Time-Series Analysis with a Scatter plot format
else if (input$Variable == "FRP_2" & input$inst_sat == "MODIS" & input$plot == "SP"){
viz_SP(MODIS_C6_TS,MODIS_C6_TS$Mean_FRP)
ggsave(file, plot = viz_SP(MODIS_C6_TS,MODIS_C6_TS$Mean_FRP) , device = "pdf")
}
else if (input$Variable == "FRP_2" & input$inst_sat == "VIIRS_SNPP" & input$plot == "SP"){
viz_SP(VIIRS_SNPP_TS,VIIRS_SNPP_TS$Mean_FRP)
ggsave(file, plot = viz_SP(VIIRS_SNPP_TS,VIIRS_SNPP_TS$Mean_FRP) , device = "pdf")
}
else if (input$Variable == "FRP_2" & input$inst_sat == "VIIRS_NOAA" & input$plot == "SP"){
viz_SP(VIIRS_NOAA_20_TS, VIIRS_NOAA_20_TS$Mean_FRP)
ggsave(file, plot = viz_SP(VIIRS_NOAA_20_TS, VIIRS_NOAA_20_TS$Mean_FRP) , device = "pdf")
}
#
else if (input$Variable == "BT_2" & input$inst_sat == "MODIS" & input$plot == "SP"){
viz_SP(MODIS_C6_TS, MODIS_C6_TS$mean_BT)
ggsave(file, plot = viz_SP(MODIS_C6_TS, MODIS_C6_TS$mean_BT) , device = "pdf")
}
else if (input$Variable == "BT_2" & input$inst_sat == "VIIRS_SNPP" & input$plot == "SP"){
viz_SP(VIIRS_SNPP_TS, VIIRS_SNPP_TS$mean_BT)
ggsave(file, plot = viz_SP(VIIRS_SNPP_TS, VIIRS_SNPP_TS$mean_BT) , device = "pdf")
}
else if (input$Variable == "BT_2" & input$inst_sat == "VIIRS_NOAA" & input$plot == "SP"){
viz_SP(VIIRS_NOAA_20_TS, VIIRS_NOAA_20_TS$mean_BT)
ggsave(file, plot = viz_SP(VIIRS_NOAA_20_TS, VIIRS_NOAA_20_TS$mean_BT) , device = "pdf")
}
})
}
shinyApp(ui = ui, server = server)