Created
December 1, 2022 10:13
-
-
Save dakvid/076fad0b6b607c4a1f0fc3d2e9cee059 to your computer and use it in GitHub Desktop.
#30DayMapChallenge 2022 | Day 25 | Two Colours
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
library(stringr) | |
library(dplyr) | |
library(sf) | |
library(rmapshaper) | |
library(roughsf) | |
# https://datafinder.stats.govt.nz | |
ta <- | |
st_read("2021/statsnz/territorial-authority-2021-clipped-generalised.gpkg") |> | |
filter(! TA2021_V1_00 %in% c("067", "999")) |> | |
ms_simplify(keep = 0.05, keep_shapes = TRUE) |> | |
st_transform(crs = 4326L) | |
ta <- | |
ta |> | |
mutate(fill = if_else(TA2021_V1_00_NAME |> str_detect("District$"), | |
"#44781e", | |
"#2c3b75"), | |
stroke = 0.5, | |
hachureangle = sample(0:180, nrow(ta), replace = TRUE)) |> | |
st_cast("POLYGON") | |
rough_ta <- | |
roughsf(list(ta), | |
roughness = 2, | |
bowing = 5, | |
simplification = 3, | |
width = 800, | |
height = 1000, | |
title = "City and District Councils of NZ", | |
title_font = "40px xkcd", | |
caption = "#30DayMapChallenge 2022 | Day 25 | 2 Colours | @dakvid", | |
caption_font = "20px xkcd") | |
save_roughsf(rough_ta, | |
"Day_25_2Colours/day_25_roughsf.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment