-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.R
172 lines (161 loc) · 8.22 KB
/
server.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
library(leaflet)
library(dplyr)
library(rgdal)
library(googleVis)
shinyServer(function(input, output, session) {
dataset1 <- reactive({df1 <- bbox[bbox$Name == input$location, ]})
## Interactive Map ###########################################################
# Create the map
output$map <- renderLeaflet({
df1 <- dataset1()
leaflet() %>%
# Base groups #
# addTiles(group = "OSM (default)") %>%
addProviderTiles("Esri.NatGeoWorldMap", group = "NatGeoWorldMap") %>%
addProviderTiles("Esri.WorldStreetMap", group = "Streets") %>%
setView(lng = df1[,"longmid"],
lat = df1[,"latmid"],
zoom=df1[,"zoomlevel"]) %>%
# Overlay groups #
addPolygons(data=adm0, weight=2, group = "Study Areas") %>%
addPolygons(data=adm1, weight=2,
group = "Admin Boundaries 1", col="yellow") %>%
# addPolygons(data=adm2, weight=2, group = "Admin Boundaries 2", col="orange") %>%
addPolygons(data=AralSea, weight=2, col="gray", group = "Aral Sea (late 1950s)") %>%
addCircles(lng = nuclearSites$Lon,
lat = nuclearSites$Lat,
fillColor = "yellow", color = "yellow",
weight = 3, radius = 10000,
popup = paste(#"<b>Country:</b>", nuclearSites$Country, "<br>",
#"<b>Location:</b>", nuclearSites$Location,"<br>",
"<b>Site:</b>", nuclearSites$Site, "<br>",
#"<b>Latitude:</b>", nuclearSites$Lat, "<br>",
#"<b>Longitude:</b>", nuclearSites$Lon, "<br>",
"<b>Description:</b>", nuclearSites$Description),
group = "Nuclear sites") %>%
addCircles(lng = SleepingTowns$Longitude,
lat = SleepingTowns$Latitude,
fillColor = "red", color = "red",
weight = 3, radius = 20000,
popup = paste("<b>Town:</b>", SleepingTowns$Towns, "<br>",
"<b>Description:</b>", SleepingTowns$Reason),
group = "Sleeping Towns") %>%
addCircles(lng = mineralResources$Longitude,
lat = mineralResources$Latitude,
fillColor = "grey", color = "grey",
weight = 3, radius = 10000,
popup = paste("<b>Site name:</b>", mineralResources$SITE_NAME,
"<br>",
"<b>Description:</b>", mineralResources$URL),
group = "Mineral Resource Data System") %>%
addCircles(lng = monitoredCities$LONGITUDE,
lat = monitoredCities$LATITUDE,
fillColor = "red", color = "red", weight = 3,
radius = ifelse(monitoredCities$POP_MAX > 1,
sqrt(abs(monitoredCities$POP_MAX))*30, 0),
group = "Populated places") %>%
addCircles(lng = populatedPlaces$LONGITUDE,
lat = populatedPlaces$LATITUDE,
fillColor = "orange", color = "orange", weight = 3,
radius = ifelse(populatedPlaces$POP_MAX > 1,
sqrt(abs(populatedPlaces$POP_MAX))*30, 0),
popup = paste("<b>",populatedPlaces$NAME, "</b><br>",
"Max population:", populatedPlaces$POP_MAX),
group = "Populated places") %>%
addCircles(lng = AirPollutionStationsEngland$Longitude,
lat = AirPollutionStationsEngland$Latitude,
fillColor = "brown", color = "brown",
weight = 3, radius = 2500,
popup = paste("<b>",
"Station name:", AirPollutionStationsEngland$Site.Name,
"</b><br>",
"Type:", AirPollutionStationsEngland$Environment.Type,
"</b><br>",
"Region:", AirPollutionStationsEngland$Region,
"</b><br>",
"Altitude:", AirPollutionStationsEngland$Altitude),
group = "AirPollutionStations") %>%
addCircles(lng = meteostationsKZ$Longitude,
lat = meteostationsKZ$Latitude,
fillColor = "blue", color = "blue",
weight = 3, radius = 10000,
popup = paste("<b>",
"Station name:", meteostationsKZ$Meteost_name,
"</b><br>",
"Oblast:", meteostationsKZ$Adm_obl,
"</b><br>",
"Region:", meteostationsKZ$Adm_region,
"</b><br>",
"Altitude:", meteostationsKZ$Altitude),
group = "Meteostations") %>%
# Layers control #
addLayersControl(
position = 'bottomleft',
baseGroups = c("NatGeoWorldMap", "Streets"),
overlayGroups = c("Study Areas",
"Admin Boundaries 1", # "Admin Boundaries 2",
"Aral Sea (late 1950s)",
"Nuclear sites",
"Sleeping Towns",
"Populated places",
"Mineral Resource Data System",
"Meteostations",
"AirPollutionStations"),
#overlayGroups = c("Nuclear sites", "AWS", "Health Risk Spots"),
options = layersControlOptions(collapsed = TRUE)
) %>%
hideGroup(c("Nuclear sites", "Populated places" ,
"Admin Boundaries 1", #"Admin Boundaries 2"
"Aral Sea (late 1950s)", "Sleeping Towns",
"Mineral Resource Data System",
"Meteostations",
"AirPollutionStations"
))
})
## Data explorer #############################################################
output$plot1 <- renderPlot({
VI <- readRDS("data/VulnerabilityIndex.rds")
plot(VI$VulnerabilityI ~ VI$Ranking,
main = "KZ and UK are not amongst the most vulnerable countries to climate change",
xlab="Ranking", ylab="Vulnerability Index")
KZ <- VI[VI$Sovereign=="Kazakhstan",]
points(KZ$VulnerabilityI ~ KZ$Ranking, col="red", pch=20, cex= 1.5)
UK <- VI[VI$Sovereign=="U.K.",]
points(UK$VulnerabilityI ~ UK$Ranking, col="blue", pch=20, cex= 1.5)
legend("topleft", pch = 20, col=c("red","blue"), legend=c("KZ","UK"))
})
# ## Project's timeline ########################################################
#
# output$timeline <- renderGvis({
#
# datTL <- data.frame(Name=c("Admin", "Data Collection", "Model Building",
# "Model Testing", "Model Debugging",
# "Paper 1", "Paper 2", "Paper 3",
# "Reporting", "Workshop"),
# Task=c("Andrew", "Allan", "Claudia",
# "Abraham", "Maged",
# "Aygul", "Sara", "Kanat", "Yelzhas", "Bella"),
# start=as.Date(x=c("2015-05-01", "2015-05-01",
# "2015-10-01", "2015-10-01",
# "2015-10-01", "2015-10-01",
# "2015-10-01", "2015-10-01",
# "2015-10-01", "2015-10-01")),
# end=as.Date(x=c("2017-03-31", "2017-03-31",
# "2017-03-31", "2017-03-31",
# "2017-03-31", "2017-03-31",
# "2017-03-31", "2017-03-31",
# "2017-03-31", "2017-03-31")))
#
# gvisTimeline(data=datTL,
# rowlabel="Name",
# barlabel="Task",
# start="start",
# end="end",
# options=list(timeline="{groupByRowLabel:false}",
# backgroundColor='#ffd',
# height=7500#,
# #colors="['#cbb69d', '#603913', '#c69c6e']"
# ))
#
# })
})