-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
87 lines (67 loc) · 3.2 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
#### Server #####
server <- function(input, output) {
speciesSelect <- reactive({
allESA <- subset(allESA,allESA$sppcode %in% input$species_dropdown)
allESA
})
yearSelect <- reactive ({
subset(speciesSelect(), speciesSelect()$survey_yea>=input$year_min
& speciesSelect()$survey_yea<=input$year_max)
})
output$text <- renderText ({
speciesSelect()$latitude
})
# output$table <- renderDT(
# DT::datatable(speciesSelect()))
output$map <- renderLeaflet({
map<-leaflet() %>%
addTiles('http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
options = providerTileOptions(noWrap = TRUE)) %>%
addTiles('http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/Mapserver/tile/{z}/{y}/{x}',
options = providerTileOptions(noWrap = TRUE)) %>%
setView(-85, 27, zoom=7) %>%
addLegend(position="bottomleft", colors=c('#e41a1c','#4daf4a', '#984ea3','#ff7f00',
'#ffff33','#a65628','#ffffvf'),
labels=c("Elkhorn Coral","Staghorn Coral","Pillar Coral", "Rough Cactus Coral",
"Lobed Star Coral", "Mountainous Star Coral", "Boulder Star Coral"))
})
observe({
map <- leafletProxy('map')
map <- map %>% leaflet::clearGroup(group='A')
map <- map %>% addCircleMarkers(lat=yearSelect()$latitude,lng=yearSelect()$longitude, color=yearSelect()$color,
stroke=FALSE, radius=3, group='A', opacity = 1)
map<-map %>% leaflet::clearGroup(group='B')
map <- if(input$hapc) return (map %>%
addPolygons(data=allHAPCs, fillColor='pink', fillOpacity=0.7,color='pink',
fill=TRUE, stroke=FALSE, group='B'))
else return (map)
# for(i in 1:length(speciesSelect())){
# map<- map %>%
# #addCircleMarkers(speciesSelect()[i],stroke=FALSE, radius=2, group='A')
# addCircleMarkers(lat=speciesSelect()[i]$latitude,lng=speciesSelect()[i]$longitude, color=speciesSelect()[i]$color,
# stroke=FALSE, radius=2, group='A')
#}
map
})
# hapcMap <- reactive({
# if(input$hapc) return (map %>%
# addPolygons(data=allHAPCs, fillColor='pink', fillOpacity=0.7,color='pink',
# fill=TRUE, stroke=FALSE))
# else return (map)
# })
table <- reactive ({
x<-ddply(yearSelect(), .(name),summarize, Depth=round(mean(depth_ft),2),
N=sum(num))
colnames(x)[colnames(x)=="name"]<- 'Species'
colnames(x)[colnames(x)=="Depth"]<- 'Avg. Depth (ft)'
x
})
# f <- ddply(allESA, .(sppcode), summarize, Depth=round(mean(depth_ft),3)
output$tbl = renderDT(
DT::datatable(table(), rownames=FALSE, style='material',
options=list(paging=FALSE, searching=FALSE))
#DT::datatable(allESA[,c(18,23),drop=TRUE])
# allESA, selection=list(selected=c(6,9,14,18,23),
# target='column')
)
}