Skip to content

Instantly share code, notes, and snippets.

@JohannesFriedrich
Created January 17, 2018 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohannesFriedrich/3eceaef02373319f57e88ef184bd5785 to your computer and use it in GitHub Desktop.
Save JohannesFriedrich/3eceaef02373319f57e88ef184bd5785 to your computer and use it in GitHub Desktop.
```{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