/
6_Blue.Rmd
100 lines (88 loc) · 2.96 KB
/
6_Blue.Rmd
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
---
title: "#30DayMapChallenge Day 6: Blue - Berlin Metro by OpenStreetMaps"
author: "Cedric Scherer"
date: "6th of October 2019"
output:
html_document:
theme: paper
highlight: kate
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning = F)
```
```{r prep}
library(tidyverse)
library(sf)
library(ggtext)
library(extrafont)
extrafont::loadfonts()
theme_set(theme_void())
theme_update(
panel.background = element_rect(fill = "black"),
plot.background = element_rect(fill = "black"),
plot.title = element_markdown(family = "Poppins",
color = "white",
size = 26,
face = "bold",
hjust = 0.5,
margin = margin(t = 12, b = 0)),
plot.caption = element_text(family = "Poppins",
color = "grey30",
size = 10,
face = "bold",
hjust = 0.5,
margin = margin(t = 0, b = 12))
)
```
```{r data-prep}
berlin_transport <- sf::read_sf(dsn = here::here("data", "osm_berlin_shp", "gis_osm_transport_free_1.shp"), layer = "gis_osm_transport_free_1")
berlin_districts <- sf::read_sf(dsn = here::here("data", "Bezirke__Berlin", "Bezirke__Berlin.shp"), layer = "Bezirke__Berlin")
berlin_transport_types <-
berlin_transport %>%
mutate(type = case_when(
str_detect(name, "^S ") & fclass %in% c("railway_station", "railway_halt") ~ "S-Bahn",
str_detect(name, "^U ") & fclass %in% c("railway_station", "railway_halt") ~ "U-Bahn",
fclass == "tram_stop" ~ "Tram",
fclass == "bus_stop" ~ "Bus",
TRUE ~ "Other"
))
```
```{r map, fig.width = 9, fig.height = 8.12}
berlin_transport_types %>%
filter(type == "U-Bahn") %>%
group_by(name) %>%
slice(1) %>% ## keep only 1 location per station
ggplot() +
## dark outline map
geom_sf(data = berlin_districts,
color = "grey15",
size = 5.5) +
## light thin outline map
geom_sf(data = berlin_districts,
color = "grey70",
size = 1.5) +
## dark borders + fill
geom_sf(data = berlin_districts,
color = "grey20",
fill = "#050523",
size = 0.6) +
## light outline points
geom_sf(color = "grey80",
size = 1.4) +
## blue points
geom_sf(color = "#0054b2",
size = 0.8) +
scale_x_continuous(limits = c(13.09, 13.76)) +
scale_y_continuous(limits = c(52.34, 52.67)) +
labs(x = NULL, y = NULL,
title = "Berlin <span style='color:#0054b2'>U-Bahn</span> Stops",
caption = "Visualization by Cédric Scherer • Data by OpenStreetMap & Geoportal Berlin")
ggsave(here::here("contributions", "Day06_Blue", "Blue_BerlinMetro.pdf"),
width = 9, height = 8.12, device = cairo_pdf)
```
***
```{r session-info}
sessionInfo()
```