Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(lubridate)
library(ggmap)
library(gganimate)
library(animation)
```
## Load data
```{r}
data <- read_delim(file = "surveyor_hackathon_data_20171212.csv",
delim = ";",
escape_double = FALSE,
col_types = cols(
sid = col_double(),
created = col_datetime(format = "%Y-%m-%d %H:%M:%S"),
link_gw_conn = col_logical()),
trim_ws = TRUE)
## remove last line:
data <- data[-nrow(data),]
```
## Analysis
```{r}
data <- data %>%
mutate(
ICE = as.factor(sid),
Satellites = sat,
day = day(created),
time = strftime(created, format = "%H:%M")
)
```
```{r filter_data}
selection <- data %>%
filter(day == 8) %>%
distinct(created, .keep_all = TRUE) %>%
arrange(created)
```
```{r get_map}
map <- get_map(location = "Germany",
zoom = 6,
source = "google",
maptype = "roadmap"
)
```
```{r plot}
p <- ggmap(map) +
geom_point(data = location,
mapping = aes(x = gps_laenge,
y = gps_breite,
frame = time,
colour = ICE,
size = Satellites,
cumulative = TRUE),
alpha = .05,
show.legend = FALSE) +
scale_radius(range = c(0.2, 6)) +
labs(x = NULL,
y = NULL) +
theme(axis.text = element_blank(),
axis.ticks = element_blank()) +
geom_text(aes(x = 4,
y = 55,
frame = time,
label = paste0("Time: ",time),
hjust = "left"),
size = 10,
data = selection)
```
```{r make_animation}
ani.options(ani.width = 1280, ani.height = 720)
gganimate(p = p,
filename = "output.gif",
saver = "gif",
interval = 0.1,
title_frame = FALSE)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment