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 / GSS-Alpha-SPARQL-Count-Concepts-By-Concept-Scheme
Created July 3, 2018 15:43
Count of the concepts in GSS ONS PMD by Concept Scheme
PREFIX qb: <http://purl.org/linked-data/cube#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT (count (distinct ?conc) as ?countconc) ?schemelab
WHERE {
?conc <http://www.w3.org/2004/02/skos/core#inScheme> ?scheme .
?scheme rdfs:label ?schemelab .
}
GROUP BY ?schemelab
ORDER BY desc(?countconc)
@northernjamie
northernjamie / GSS-Alpha-SPARQL-Count-Concept-Schemes
Created July 3, 2018 15:23
Count concept schemes in the GSS Alpha ONS triple store
PREFIX qb: <http://purl.org/linked-data/cube#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT (count (distinct ?concsch) as ?countconc)
WHERE {
?concsch a <http://www.w3.org/2004/02/skos/core#ConceptScheme> .
?concsch rdfs:label ?concschlab .
}
@northernjamie
northernjamie / GSS-Alpha-Count-Observations-By-Dataset
Created July 3, 2018 08:11
Count observations by dataset in ONS GSS Alpha PMD
PREFIX qb: <http://purl.org/linked-data/cube#>
SELECT (count (distinct ?s) as ?counts) ?ds
WHERE {
?s a <http://purl.org/linked-data/cube#Observation> ;
qb:dataSet ?ds .
}
GROUP BY ?ds
@northernjamie
northernjamie / GSS-Alpha_SPARQL-Count-Observations
Created July 3, 2018 07:58
Count observations in GSS alpha ONS PMD
SELECT (count (distinct ?s) as ?counts)
WHERE {
?s a <http://purl.org/linked-data/cube#Observation>
}
@northernjamie
northernjamie / GSS-Alpha-SPARQL-Count-Triples
Created July 3, 2018 07:55
Count the number of triples in the GSS Alpha ONS PMD
SELECT (count (?s) as ?counts)
WHERE {
?s ?p ?o
}
@northernjamie
northernjamie / GSS-Alpha-SPARQL-Count-Datasets
Created July 3, 2018 07:51
Count the number of datasets in ONS GSS Alpha PMD
PREFIX qb: <http://purl.org/linked-data/cube#>
SELECT (count (distinct ?o) as ?counto)
WHERE {
?s qb:dataSet ?o
}
@northernjamie
northernjamie / ODC_Google_Chart_SPARQL_1_Line.SPARQL
Created January 30, 2018 14:46
SPARQL query to get one series of data for ODC google chart demo
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?periodlabel ?count
WHERE {
?obs <http://purl.org/linked-data/cube#dataSet> <http://opendatacommunities.org/data/homelessness/rough-sleeping/count> .
?obs <http://opendatacommunities.org/def/ontology/geography/refArea> <http://opendatacommunities.org/id/geography/administration/ctry/E92000001> .
?obs <http://opendatacommunities.org/def/ontology/time/refPeriod> ?perioduri .
?obs <http://opendatacommunities.org/def/ontology/homelessness/roughSleepingObs> ?count .
?perioduri rdfs:label ?periodlabel .
}
ORDER BY ?periodlabel
@northernjamie
northernjamie / scraperbbcpollution.py
Created January 12, 2018 22:03
Python script for scraping pollution data from bbc / earthsense website
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
import time
import csv
path_to_chromedriver = '/Users/Jamie/Projects/Propolis_Stuff/chromedriver' # change path as needed
@northernjamie
northernjamie / ODC_SPARQL_GChart_Demo_2_Areas.SPARQL
Created December 12, 2017 11:06
SPARQL query that powers the Google Chart demo with two series of data from OpenDataCommunities - rough sleepers in Brighton and Manchester
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?periodlabel ?countb ?countm
WHERE {
?obsm <http://purl.org/linked-data/cube#dataSet> <http://opendatacommunities.org/data/homelessness/rough-sleeping/count> ;
<http://opendatacommunities.org/def/ontology/geography/refArea> <http://opendatacommunities.org/id/geography/administration/md/E08000003> ;
<http://opendatacommunities.org/def/ontology/time/refPeriod> ?perioduri ;
<http://opendatacommunities.org/def/ontology/homelessness/roughSleepingObs> ?countm .
<http://opendatacommunities.org/id/geography/administration/md/E08000003> rdfs:label ?aream .
?obsb <http://purl.org/linked-data/cube#dataSet> <http://opendatacommunities.org/data/homelessness/rough-sleeping/count> ;
@northernjamie
northernjamie / ODC_Google_Chart_Demo_Full_Code.html
Created December 6, 2017 15:23
Demonstration of creating a google chart from a SPARQL query on open data communities full html code
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script src='https://code.jquery.com/jquery-3.2.1.min.js'></script>
<script type="text/javascript">
//Set the url of the SPARQL endpoint
var url = 'http://opendatacommunities.org/sparql.json';