Skip to content

Instantly share code, notes, and snippets.

library(dplyr)
library(lubridate)
library(ggplot2)
library(readr)
source("~/theme.R")
Rain <- read_csv("2810__Rain__daily.csv")
Gust <- read_csv("2810__Gust__daily.csv")
col_background = "#DDDDDD"
col_rain = "#56B4E9"
geo iso3c iso2c nabs07_2 RD_sum RD_percent pop_2023 gdp_pc_2023_USD
Austria AUT AT Agriculture 94.776 7.944888081 9131761 56579.50418
Austria AUT AT Society 79.743 6.684700876 9131761 56579.50418
Austria AUT AT Defence 7.332 0.614627326 9131761 56579.50418
Austria AUT AT Energy 117.083 9.814840584 9131761 56579.50418
Austria AUT AT Environment 42.761 3.584571613 9131761 56579.50418
Austria AUT AT Exploration and exploitation of space 29.572 2.478963349 9131761 56579.50418
Austria AUT AT Exploration and exploitation of the earth 57.199 4.794881123 9131761 56579.50418
Austria AUT AT Health 195.342 16.37514062 9131761 56579.50418
Austria AUT AT Industrial production and technology 519.87 43.57969282 9131761 56579.50418
# site locations
# https://opendata-nzta.opendata.arcgis.com/datasets/b90f8908910f44a493c6501c3565ed2d_0/explore?location=-40.549980%2C173.382464%2C6
# download of full data as csv as of 2026-04-02, approx 385KB
# traffic counters
# https://opendata-nzta.opendata.arcgis.com/datasets/898e77d403c443c4961ada073d144735_0/explore
# download of full data as csv as of 2026-04-01, approx 800MB
# road outline map
@thoughtfulbloke
thoughtfulbloke / NZTA.r
Last active March 31, 2026 00:02
NZTA TMS traffic count processing
library(dplyr)
library(lubridate)
library(readr)
library(ggplot2)
source("~/theme.R")
# known site aliases of interest from data exploration of complete data sites
# in places I am personally invested in knowing about
sites_of_interest <- c(621, 620)
# get a clipped map of territorial authorities, like
# https://koordinates.com/from/datafinder.stats.govt.nz/layer/123496-territorial-authority-2026-clipped/
# download (needs registration) in a format useful you. I used
# Coordinate Reference System WGS 84 (EPSG:4326)) and as a .kml file (21MB)
#
# download territorial population like from
# https://infoshare.stats.govt.nz Population : Population Estimates (DPE)
# Estimated Resident Population for Territorial Authority Areas, at 30 June(1996+) (Annual-Jun)
# as a csv for the year 2025
#
library(readr)
library(dplyr)
library(tidyr)
library(lubridate)
library(ggplot2)
library(ggthemes)
gn <- read_csv("202601_Generation_MD.csv")
ex <- read_csv("202601_Grid_export.csv")
@thoughtfulbloke
thoughtfulbloke / theme.R
Last active February 5, 2026 23:59
My standard gig-lot theme as of February 2026
library(ggplot2)
library(ggthemes)
six_cols <- colorblind_pal()(6)
make_footer <- function(x){
paste0(x,"\n Made by David Hood, ", Sys.Date())
}
bodyfont <- "Lexend Deca Thin"
BCDate ANZBC GDPI_income_actual GDPI_income_seasonallyAdjusted
2008-01-30
2008-04-30 -54.8
2008-05-27 -49.7
2008-06-30 -38.7
2008-07-31 -43.2
2008-08-27 -20.5
2008-09-30 1.6
2008-10-30 -42.3
2008-11-27 -43
@thoughtfulbloke
thoughtfulbloke / fluSARI22to25.csv
Last active December 20, 2025 08:02
Auckland Influenza SARI rates extracted from NZ PHFS Respiratory Illness Dashboard
Weekn Yearn WeekEnding Rate100k
1 2022 2022-01-05 0
2 2022 2022-01-12 0
3 2022 2022-01-19 0
4 2022 2022-01-26 0
5 2022 2022-02-02 0
6 2022 2022-02-09 0
7 2022 2022-02-16 0
8 2022 2022-02-23 0
9 2022 2022-03-02 0
@thoughtfulbloke
thoughtfulbloke / night.R
Created November 12, 2025 08:30
Night at 2025-11-12 21:25 NZDT
library(dplyr)
library(geosphere)
library(suncalc)
library(lubridate)
library(mapdata)
source("~/theme.R")
#21:25 locally is UTC 2025-11-11 08:25:00 at this time of year
# -47.5, 166
# -34.5, 180