Skip to content

Instantly share code, notes, and snippets.

@dakvid
dakvid / population_grid.R
Created November 2, 2021 08:41
Process NZ population data into grid points from SA2s
# Create a bubble grid of New Zealand population using
# data for Statistical Areas 2
# For #30DayMapChallenge day 1 - points
# -- David Friggens, November 2021
library(readr)
library(sf)
# Get the centroids for SA2s
# From https://datafinder.stats.govt.nz
@dakvid
dakvid / maori_streets.R
Created November 2, 2021 10:31
A coloured map of the language of street names
# Create a map of Waikanae streets coloured by whether the name is Māori or English
# using OpenStreetMap data, with some inspiration from
# https://erdavis.com/2019/07/27/the-beautiful-hidden-logic-of-cities/
# https://github.com/erdavis1/RoadColors
# For #30DayMapChallenge 2021 day 2 - lines
# -- David Friggens, November 2021
library(magrittr)
library(stringr)
@dakvid
dakvid / local_board_ploygons.R
Created November 6, 2021 17:48
Plot the outlines of Auckland's local board areas
# #30DayMapChallenge 2021 - Day 3 - Polygons
# Displaying the local board ares of Auckland
# -- David Friggens, November 2021
library(magrittr)
library(dplyr)
library(tidyr)
library(stringr)
library(purrr)
library(sf)
@dakvid
dakvid / connections2.R
Created November 9, 2021 10:17
Map connecting each New Zealand settlement with it's nearest largest neighbour
# Map connecting each New Zealand settlement with it's nearest largest neighbour
# For #30DayMapChallenge 2020, day 15 (connections)
# Inspired by https://twitter.com/AndriyYaremenko/status/1327885776047239168
# -- David Friggens, December 2020
library(dplyr)
library(stringr)
library(tidyr)
library(sf)
library(ggplot2)
@dakvid
dakvid / dorling.R
Last active November 9, 2021 10:19
Create Dorling Cartograms of NZ election results
# Create Dorling Cartograms of NZ election results
# For #30DayMapChallenge 2020 days 5-9
# -- David Friggens, November 2020
library(magrittr)
library(glue)
library(readr)
library(dplyr)
library(tidyr)
library(sf)
@dakvid
dakvid / rata.R
Created November 13, 2021 03:27
#30DayMapChallenge 2021 - Day 06 - Red
# 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()
@dakvid
dakvid / wellington_cbd.R
Created November 13, 2021 04:15
#30DayMapChallenge 2021 - Day 08 - Blue
# The monochrome cityscape of Wellington, inspired by several blog
# posts and challenge submissions (haven't noted them all).
# I used my work's dark blue and highlighted the office building.
# It didn't stand out as much as I expected (obvious in hindsight)
# but I left it in anyway. :-)
# -- David Friggens, November 2021
# Setup -------------------------------------------------------------------
@dakvid
dakvid / kapiti_bw.R
Created November 16, 2021 09:39
#30DayMapChallenge 2021 - Day 10 - Raster - 3D Kāpiti Island with rayshader
# Make a black and white elevation map of Kāpiti Island, New Zealand
# adapting https://github.com/AmitLevinson/30daymapchallenge/blob/main/2021/09_monochrome/monochrome.R
# for #30DayMapChallenge 2021 - Day 10 - Raster
# -- David Friggens, November 2021
library(elevatr)
library(rayshader)
library(sf)
library(dplyr)
@dakvid
dakvid / gist:b1f4b3854f4c1f2fa5668c178b729ce2
Created November 18, 2021 00:36
#30DayMapChallenge 2021 - Day 11 - 3D
# Create a 3d plot of Christchurch population density
# for #30DayMapChallenge 2021 - Day 11 - 3D
# -- David Friggens, November 2021
# Really helped by Iva Brunec to get this to work!
# https://github.com/ivabrunec/30daymapchallenge/blob/main/scripts/day11_3D.R
# Data preparation more general to allow more areas to be done,
# but decided to just do one for now and come back later!
@dakvid
dakvid / street_grid.R
Created November 21, 2021 08:28
#30DayMapChallenge 2021 - Day 07 - Green
# Street orientation grids of New Zealand cities
# for #30DayMapChallenge 2021 - Day 07 - Green
# -- David Friggens, November 2021
# Inspired by:
# Geoff Boeing
# https://geoffboeing.com/2018/07/comparing-city-street-orientations/
# https://geoffboeing.com/2019/09/urban-street-network-orientation/
# Erin Davis
# https://erdavis.com/2019/11/21/street-network-orientation-by-road-type/