-
Notifications
You must be signed in to change notification settings - Fork 1
/
ui.R
152 lines (139 loc) · 5.97 KB
/
ui.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
# # plot transforms
# f = '~/github/dissertation/fig/routing/shortestPath_transforms.pdf'
# pdf(f)
# plot(x, col=fields::two.colors(start='darkblue', end='red', middle='white', alpha=.5))
# cols = fields::tim.colors(length(transforms))
# for (i in 1:length(transforms)){ # i=16
# lines(spTransform(routes[[i]]$route, crs(epsg3857)), col=cols[i], lwd=2)
# }
# legend('bottomleft', as.character(transforms), col=cols, lwd=2)
# dev.off()
# system(sprintf('open %s', f))
# ui ----
#ui <- fluidPage(
shinyUI(fluidPage(
useShinyjs(),
navbarPage(
"Conservation",
tabPanel(
"Routing", icon = icon('road'),
fluidRow(
helpText(HTML(renderMarkdown(text="**Instructions.** Click on a point in the tradeoff chart below to display the mapped route to the left and values below.
Map is zoomable/pannable and begin/end points changable.")))),
hr(),
fluidRow(
column(
3,
selectInput(
'sel_extent', 'Study Area:',
extents %>%
filter(routing==T) %$%
split(.[,c('name','code')], country) %>%
lapply(function(x) setNames(x$code, x$name)),
selected=default_study),
selectInput(
'sel_spp', 'Species:',
data_frame(
group='All', name='Composite species risk', code='ALL') %>%
rbind(
spp %>%
arrange(group, name) %>%
select(group, name, code)) %$%
split(.[,c('name','code')], group) %>%
lapply(function(x) setNames(x$code, x$name)))),
column(
3,
selectInput(
'sel_beg', 'Begin:',
nodes %$%
split(.[,c('name','code')], group) %>%
lapply(function(x) setNames(x$code, x$name)),
selected=default_beg),
hidden(textInput('txt_beg', 'point begin code', value=default_beg)),
selectInput(
'sel_end', 'End:',
nodes %$%
split(.[,c('name','code')], group) %>%
lapply(function(x) setNames(x$code, x$name)),
selected=default_end),
hidden(textInput('txt_end', 'point end code', value=default_end))),
column(
2, br(), br(), br(),
actionButton('btn_reroute', 'Reroute')),
column(
4, br(), br(),
selectInput(
'sel_industry', 'Industry Profile:',
c('Oil Tanker'='rt_oil','Shipping Tanker'='rt_ship','Cruise Ship'='rt_cruise')),
hidden(helpText(
id='hlp_industry',
'Eventually these industry profiles will enable customized species responses depending on types of impact.')))),
fluidRow(
column(
8,
leafletOutput('map', height='400px')),
column(
4, #
hidden(textInput('txt_transform', 'selected transform', value = default_transform)),
div(
style = "height:400px; background-color:#f5f5f5",
ggvisOutput("ggvis")))),
hr(),
fluidRow(
column(
8,
helpText(HTML(renderMarkdown(
text='**Background.** Welcome to Conservation Routing! Least cost routes are calculated based on different cost surfaces.
The initial cost surface applies a constant value for all cells resulting in a Euclidean path
with the minimum distance. This path would be the least costly to industry, making it
the reference point (_min(dist)_) to which other routes are compared. Other paths are calculated
by applying transformations to the conservation risk surface, which is calculated as the cumulative species score
weighted by extinction risk. The summation of conservation risk values traversed by the path determines
the conservation score. The reference point (_min(cost)_) is subtracted from all values.')))),
column(
4,
#DT::dataTableOutput('dt_tbl'))
p(
"Tradeoff selected: ",
uiOutput('txt_tradeoff')
))),
hr(),
fluidRow(
column(
8,
helpText(HTML(renderMarkdown(
text="**Conservation Risk**. The conservation risk surface is a cumulative species hotspot map that
provides the cost against which the least-cost path is routed. This surface is constructed from the
individual species distribution maps which are weighted by the species' extinction risk before each
pixel is summed. Finally the resistance surface is divided by the maximum value to normalize it to
a maximum of 1."))),
withMathJax(helpText(
"More formally, each pixel (\\(i\\)) across \\(n\\) species (\\(s\\)) is summed by its
relative density (\\(z_i\\)), which is based on the pixel values' (\\(x_i\\)) deviation (\\(\\sigma_s\\)) from
mean density (\\(\\mu_s\\)), and multiplying by the species' extinction risk weight (\\(w_s\\)):
$$
z_{i,s} = \\frac{ x_{i,s} - \\mu_s }{ \\sigma_s } \\\\
Z_i = \\frac{ \\sum_{s=1}^{n} z_{i,s} * w_s }{ n }
$$"))),
column(
4,
# speceis weight plot
plotOutput('plt_spp_weights')))),
tabPanel(
"Siting", icon = icon('map-marker'),
fluidRow(
column(
8,
leafletOutput('map_sit', height='400px')) #,
# column(
# 4, #
# hidden(textInput('txt_sit_transform', 'selected transform', value = default_transform)),
# div(
# style = 'height:400px; background-color:#f5f5f5',
# ggvisOutput('ggvis_sit')))
),
fluidRow(
h2('Static Mockup'),
p("Here's an idea of what the interface will look like:"),
img(src='img/lucidchart/Siting.png'),
img(src='img/lucidchart/Map_Popup.png'))))))