-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.R
70 lines (57 loc) · 2.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
library(shiny)
library(tidyverse)
library(rgdal)
library(gifski)
library(gganimate)
library(lubridate)
library(sf)
df <- read_csv("final_data.csv")
coord <- read_csv("coords2.csv")
coord <- coord %>%
rename(longitude=lon) %>%
rename(latitude=lat)
df %>%
left_join(coord, by=c("Ort"="Ort")) %>%
mutate(sw_lat=53.916667,sw_long=14.25) %>%
mutate(Datum=as.Date(Datum)) %>%
mutate(year=year(Datum))->
data
# Download data from https://hub.arcgis.com/datasets/ae25571c60d94ce5b7fcbf74e27c00e0/about
st_read("./europe/Europe.shp") %>%
st_transform(crs = '+proj=aeqd +lat_0=53.6 +lon_0=12.7') %>%
st_simplify(preserveTopology = FALSE, dTolerance = 10000) ->
europa
if (interactive()) {
ui <- fluidPage(
titlePanel("Kulturhackathon 2022 - Projekt SwineBad"),
img(src = "Swinemuende_vor_100_Jahren.jpg", height=200),
img(src = "Badanzeiger_Titelpage.png", height=200),
sliderInput("date", "date of arrival:",
min =as.Date("1910-06-06","%Y-%m-%d"),
max =as.Date("1932-12-31","%Y-%m-%d"),
value=as.Date("1910-06-06"),
timeFormat="%Y-%m-%d",
animate = TRUE),
plotOutput("Plotyplot"),
img(src = "KH_code_expedition.png", height=100),
img(src = "ords-sticker-hex-mv.png", height=100),
)
server <- function(input, output) {
output$Plotyplot <- renderPlot({
# data$year <- format(as.Date(data$Datum, format="%Y-%m-%d"),"%Y")
data1 <- data[data$Datum==input$date,]
ggplot(europa)+
geom_sf(fill="beige") +
annotate("point", y=53.916667,x=14.25, colour = "red", size = 1) +
geom_segment(data=data1,color="#d73027",
aes(xend=sw_long, yend=sw_lat, x = longitude, y = latitude),
arrow = arrow(length = unit(3, "mm"))) +
coord_sf(xlim = c(0, 30), ylim = c(40, 60), expand = FALSE, crs = 4326) +
theme_minimal()+
theme(axis.title.x=element_blank(),
axis.title.y=element_blank(),
panel.background = element_rect(fill="lightblue"))
})
}
shinyApp(ui = ui, server = server)
}