Skip to content

Instantly share code, notes, and snippets.

@dakvid
Created December 1, 2022 10:13
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 dakvid/076fad0b6b607c4a1f0fc3d2e9cee059 to your computer and use it in GitHub Desktop.
Save dakvid/076fad0b6b607c4a1f0fc3d2e9cee059 to your computer and use it in GitHub Desktop.
#30DayMapChallenge 2022 | Day 25 | Two Colours
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