Created
November 13, 2021 03:27
-
-
Save dakvid/a6ef2412ada0de051dac7b6fbe089d94 to your computer and use it in GitHub Desktop.
#30DayMapChallenge 2021 - Day 06 - Red
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Transform lines to all start from the same origin | |
# Specifically every "Rata Street" so it looks (a bit) like a rata flower | |
# for #30DayMapChallenge day 06 - red | |
# -- David Friggens, November 2021 | |
library(dplyr) | |
library(sf) | |
library(ggplot2) | |
library(showtext) | |
showtext_auto() | |
font_add_google("Patrick Hand", "patrick_hand") | |
RATA_FONT <- "patrick_hand" | |
RATA_RED <- "#f53a49" | |
# I wrote this using linestrings from OSM, but it works | |
# fine with the multilinestrings used here | |
originise_line <- | |
function(my_linestring) { | |
my_crs <- st_crs(my_linestring) | |
my_origin <- | |
my_linestring %>% | |
st_cast("POINT") %>% | |
head(1) | |
originised_line <- my_linestring - my_origin | |
st_crs(originised_line) <- my_crs | |
return(originised_line) | |
} | |
# https://data.linz.govt.nz/layer/53382-nz-roads-addressing/ | |
roads <- | |
read_sf("roads/nz-roads-addressing.gpkg") | |
rata_streets <- | |
roads %>% | |
filter(full_road_name == "Rata Street") | |
rata_streets %>% | |
rowwise() %>% | |
mutate(geom = originise_line(geom)) %>% | |
ggplot() + | |
geom_sf(colour = RATA_RED) + | |
theme_void(base_size = 36, | |
base_family = RATA_FONT) + | |
labs(title = "Rata Street, New Zealand (yes - all 57 of them)", | |
subtitle = "#30DayMapChallenge 2021 - Day 06 - Red", | |
caption = "Map: David Friggens @dakvid. Data: Toit\u16b Te Whenua LINZ") + | |
theme(plot.title = element_text(colour = RATA_RED, | |
hjust = 0.5), | |
plot.subtitle = element_text(colour = RATA_RED, | |
hjust = 0.5), | |
plot.caption = element_text(colour = RATA_RED, | |
hjust = 0.5)) | |
ggsave("Day_06/Day_06_rata_street.png", width = 8, height = 4) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment