Skip to content

Instantly share code, notes, and snippets.

View northernjamie's full-sized avatar

Jamie Whyte northernjamie

  • Propolis Open Data Factory
  • Manchester, UK
View GitHub Profile
@northernjamie
northernjamie / get-bus-data-for-gif.R
Last active August 7, 2021 07:36
Thie is an R script that gets real time bus data from DfT, and makes a series of maps and saves as images for making a gif.
library(tidyverse)
library(leaflet)
library(httr)
library(sp)
library(rgdal)
library(mapview)
library(xml2)
library(RColorBrewer)
@northernjamie
northernjamie / g20_hex_viz.R
Created March 4, 2021 22:20
r script for processing the data for the spinning hex visualisation
library(tidyverse)
library(colorspace)
library(audio)
options(scipen=100)
# get the international data from Our World in Data (already downloaded)
international_data <- read_csv("data/owid_international_2021_02_26.csv")
@northernjamie
northernjamie / covid_sonification.R
Last active November 14, 2020 11:42
R script for getting england covid-19 data and processing it for making a song and animated line chart
# single script to get the data for England, animate the line chart and make the .wav file
#libraries
library(tidyverse) # for munging the data
library(audio) # to mmake the wav file
library(gganimate) # to animate the line chart
library(zoo) # for the rolling average
# get and prepare the data ----
from PIL import Image
import glob
import time
# create an empty list called images
images = []
# get the current time to use in the filename
timestr = time.strftime("%Y%m%d-%H%M%S")
@northernjamie
northernjamie / sparql-sg-training-exercise-3
Created March 26, 2019 09:49
Alcohol-related hospital discharges by Council area - 2016/17
PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX qb: <http://purl.org/linked-data/cube#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sdmx: <http://purl.org/linked-data/sdmx/2009/concept#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX void: <http://rdfs.org/ns/void#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
We can't make this file beautiful and searchable because it's too large.
"repDate","name","value","year","lastValue","monthno","group"
"2015-05-01","City of Derby",137460.0762,2015,137460.0762,245,"East Midlands"
"2001-12-01","City of Derby",60493.55855,2001,60493.55855,84,"East Midlands"
"2004-01-01","City of Derby",104635.3407,2004,104635.3407,109,"East Midlands"
"2004-04-01","City of Derby",106620.5638,2004,106620.5638,112,"East Midlands"
"2017-06-01","City of Derby",151598.6005,2017,151598.6005,270,"East Midlands"
"2016-01-01","City of Derby",140878.6028,2016,140878.6028,253,"East Midlands"
"1998-07-01","City of Derby",42714.03835,1998,42714.03835,43,"East Midlands"
"1995-06-01","City of Derby",39736.716,1995,39736.716,6,"East Midlands"
"2014-04-01","City of Derby",130099.4221,2014,130099.4221,232,"East Midlands"
We can't make this file beautiful and searchable because it's too large.
"repDate","name","value","year","lastValue","monthno","group"
"2009-04-01","Hartlepool",105193.8233,2009,105193.8233,172,"North East"
"2000-01-01","Hartlepool",43937.756,2000,43937.756,61,"North East"
"2015-10-01","Hartlepool",102929.3792,2015,102929.3792,250,"North East"
"1997-07-01","Hartlepool",39946.00189,1997,39946.00189,31,"North East"
"2018-02-01","Hartlepool",104594.3429,2018,104594.3429,278,"North East"
"2003-11-01","Hartlepool",69377.30951,2003,69377.30951,107,"North East"
"1999-12-01","Hartlepool",44794.55102,1999,44794.55102,60,"North East"
"2002-01-01","Hartlepool",44817.86181,2002,44817.86181,85,"North East"
"1998-09-01","Hartlepool",43179.20586,1998,43179.20586,45,"North East"
We can't make this file beautiful and searchable because it's too large.
"repDate","name","value","year","lastValue","monthno","group"
"2009-04-01","Hartlepool",105193.8233,2009,105193.8233,172,"North East"
"2000-01-01","Hartlepool",43937.756,2000,43937.756,61,"North East"
"2015-10-01","Hartlepool",102929.3792,2015,102929.3792,250,"North East"
"1997-07-01","Hartlepool",39946.00189,1997,39946.00189,31,"North East"
"2018-02-01","Hartlepool",104594.3429,2018,104594.3429,278,"North East"
"2003-11-01","Hartlepool",69377.30951,2003,69377.30951,107,"North East"
"1999-12-01","Hartlepool",44794.55102,1999,44794.55102,60,"North East"
"2002-01-01","Hartlepool",44817.86181,2002,44817.86181,85,"North East"
"1998-09-01","Hartlepool",43179.20586,1998,43179.20586,45,"North East"
@northernjamie
northernjamie / nhs-geosparql-example
Created July 23, 2018 07:31
Example of geosparql on the NHS PublishMyData platform. Medical organisations with 5km of Alder Hey Children's Hospital
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix unit: <http://qudt.org/vocab/unit#>
SELECT DISTINCT ?name ?loc ?geo ?selhosp
WHERE {
?loc rdfs:label ?name .
?loc geo:hasGeometry ?geo .
@northernjamie
northernjamie / GSS-Alpha-SPARQL-Count-Concepts
Created July 3, 2018 15:50
Count of the concepts in the GSS alpha ONS PMD
PREFIX qb: <http://purl.org/linked-data/cube#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT (count (distinct ?conc) as ?countconc)
WHERE {
?conc <http://www.w3.org/2004/02/skos/core#inScheme> ?scheme .
}