Where the English monarchs died

By | October 28, 2014

(according to Wikipedia)

This was a quick and dirty experiment to see how easy it is to auto generate an interactive map from Wikipedia/DBpedia. There are some caveats and things I still need to iron out.

These are people that Wikipedia has described as a Monarch of England, they must have a place of death listed in Wikipedia and that place of death must have longitude and latitude in http://www.georss.org/georss/

There are loads more things I would like to do to the map, but I was pleased at how quick you can map things from Wikipedia. I could perhaps add how they died. There also seems to be some encoding problems and the description boxes seem to cut off.

Remember this is completely automated from Wikipedia data. Data might not be completely correct; worrying about that is for part two as I just need the process in place for another project.

Click the dots for details.

The process was quite easy but there are some steps I could do with removing:

1) Write SPARQL query that looks like this:

SELECT ?person ?name ?died ?gps ?label WHERE {
      ?person dcterms:subject category:English_monarchs .
      ?person foaf:name ?name .
      ?person dbpedia-owl:deathPlace ?died .
      ?died grs:point ?gps .
      ?died rdfs:label ?label
       FILTER(LANG(?label) = '' || LANGMATCHES(LANG(?label), 'en'))
               }

2)Grab CSV based on SPARQL, use Open Refine to do some housekeeping

3)Upload to Google Fusiontables

Here is the script I wrote in R to generate the CSV:

install.packages('SPARQL')
library(SPARQL)
endpoint <- "http://live.dbpedia.org/sparql"
options <- NULL

query = "

PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX category: <http://dbpedia.org/resource/Category:>
prefix grs: <http://www.georss.org/georss/>

SELECT ?person ?name ?died ?gps ?label WHERE {
      ?person dcterms:subject category:English_monarchs .
      ?person foaf:name ?name .
      ?person dbpedia-owl:deathPlace ?died .
      ?died grs:point ?gps .
      ?died rdfs:label ?label
       FILTER(LANG(?label) = '' || LANGMATCHES(LANG(?label), 'en'))
               }
"

qd <- SPARQL(endpoint,query)
df <- qd$results
write.csv(df, file = "kingsanddeaths.csv")

 

One thought on “Where the English monarchs died

  1. Pingback: The birth place of every pro wrestler ever (according to wikipedia) | David Sherlock

Leave a Reply

Your email address will not be published. Required fields are marked *