-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtab-habitatmask.R
202 lines (195 loc) · 17.2 KB
/
tab-habitatmask.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
tabhabitat <- tabPanel("Habitat mask",
fluidRow(
column(3,
tabsetPanel(
type = "pills", id = "masktype", selected = "Build",
# build mask by buffering around traps
tabPanel("Build",
wellPanel(class = "mypanel",
fluidRow(
column(6,
numericInput("buffer", "Buffer width (m)",
min = 0,
max = 100000,
value = 100,
step = 5,
width = 160)
),
column(6,
br(),
tags$div(style="text-align: right",
actionLink("suggestbufferlink", HTML("<small>suggest width</small>"),
title = "Based on RPSV(ch, CC = TRUE); RB <= 0.1%")
)
)
),
fluidRow(
column(12,
radioButtons("meshdimensionbtn", label = "Specify mesh by -",
choices = c("Number in x-direction ", "Spacing"),
selected = "Number in x-direction ", inline = TRUE))
),
fluidRow(
column(6,
tags$div(title = "Resolution of mesh - number of columns in x-direction",
numericInput("habnx", "nx",
min = 10,
max = 1000,
value = 32,
step = 1,
width = 160)
)
),
column(6,
numericInput("habspacing", "spacing m",
min = 1,
max = 10000,
value = 10,
step = 1,
width = 160)
)
),
fluidRow(
column(9,
tags$div(title = "Mask type 'trapbuffer' is trimmed to exclude points further than the buffer distance from any detector",
radioButtons("maskshapebtn", label = "Shape",
choices = c("Rectangular", "Trap buffer"),
selected = "Trap buffer", inline = TRUE)
)
),
column(3,
br(),
tags$div(style = "text-align: right",
actionLink("clearbufferspec", HTML("<small>reset</small>"))
)
)
)
),
wellPanel(class = "mypanel",
tags$div(title = "Polygons can be used to clip the mask",
radioButtons("maskpolybtn", label = "Mask polygon source",
choices = c("None", "File(s)", "R object"),
selected = "None", inline = TRUE)
),
conditionalPanel( condition = "input.maskpolybtn == 'File(s)'",
div(style="height: 80px;",
fileInput("maskpolyfilename",
paste0("Polygon file(s)", strrep(intToUtf8(160), 3)),
accept = c('.shp','.dbf','.sbn','.sbx',
'.shx',".prj", ".txt", ".rdata", ".rda", ".rds"),
multiple = TRUE)
),
uiOutput("habitatfile")
),
conditionalPanel( condition = "input.maskpolybtn == 'R object'",
div(style="height: 80px;",
# need also to load polyrv$data
textInput("maskpolyobjectname", "Polygon object",
value = "", placeholder = "e.g., GSM")
)),
conditionalPanel ("output.maskpolygonsready",
fluidRow(column(9,
tags$div(title = "Do polygons represent habitat ('include') or non-habitat ('exclude')?",
radioButtons("includeexcludebtn", label = "",
choices = c("Include", "Exclude"),
selected = "Include", inline = TRUE)
),
),
column(3,
br(),
tags$div(style="text-align: right",
actionLink("clearpolygondata", HTML("<small>clear</small>"))
)
)
)
)
),
wellPanel(class = "mypanel",
tags$div(title = "Optional mask covariates",
radioButtons("maskcovariatebtn", label = "Mask covariate source",
choices = c("None", "File(s)"),
selected = "None", inline = TRUE)
),
conditionalPanel( condition = "input.maskcovariatebtn == 'File(s)'",
div(style="height: 80px;",
fileInput("maskcovariatefilename",
paste0("Spatial data source for covariates"),
accept = c('.shp', '.dbf', '.sbn', '.sbx',
'.shx', '.prj', '.txt', '.rds'),
multiple = TRUE)),
uiOutput("covariatefile"),
conditionalPanel ("output.maskcovariatefileready",
fluidRow(
column(10,
checkboxInput("dropmissing",
"Drop point if any covariate missing", value = FALSE)
),
column(2,
tags$div(style="text-align: right",
actionLink("filtermask", HTML("<small>filter</small>")),
br(),
actionLink("clearspatialdata", HTML("<small>clear</small>"))
)
)
),
conditionalPanel("output.filterMask",
fluidRow(
column(12, textInput("filtermasktext", "Filter",
placeholder = "e.g., forest == 'beech'"))
)))
)
)
),
# mask input from file
tabPanel("File",
wellPanel(class = "mypanel",
div(style = "height: 80px;",
fileInput("maskfilename", "Mask file",
accept = c('.txt'),
multiple = FALSE))
)
)
),
fluidRow(
column(6, actionLink("mainlink", "Return to Main screen")),
column(6, conditionalPanel ("output.maskready",
downloadLink("savemask", "Save mask to text file")))
)
),
column(5, plotOutput("maskPlot"),
conditionalPanel ("output.maskready",
fluidRow(
column(3, offset = 1,
checkboxInput("dotsbox", "dots", value = FALSE)),
column(2, checkboxInput("frame", "frame", value = TRUE)),
column(3,
checkboxInput("maskedge2", "show edge", value = FALSE),
conditionalPanel ("output.maskcovariatesready",
checkboxInput("legend", "legend", value = FALSE)
)
),
column(2,
conditionalPanel ("output.maskpolygonsready",
checkboxInput("showpoly", "polygon(s)", value = FALSE)
)
),
column(3,
conditionalPanel ("output.maskcovariatesready",
selectInput("maskcov", "Covariate", choices = "none")
),
conditionalPanel("output.multisession=='true'",
numericInput("masksess", "Session", min = 1, max = 2000,
step = 1, value = 1))
)
)
)
),
column(3,
h2("Summary"),
fluidRow(
column(12,
verbatimTextOutput("maskPrint"))
)
)
)
)