Check out the Home Town Bands Map Hack!
This is what our team achieved at the Kasabi Culture Hack Day today (Thank you Michael, Rick, Bee and especially Benji who taught us sparql and did a fantastic design for the page – as well as to the Kasabi team who were very patient and helpful).
These maps show the home towns of bands listed on wikipedia/dbpedia. See these examples for Germany, United Kingdom and Canada. To see another country, replace Germany, United_Kingdom or Canada at the end of the url with the country name you want.
Benji created an interface for the maps here. The maps have varying amounts of information for each country, mainly due to some gaps in the dbpedia dataset. Think of it as a prototype, people!
http://culturehack.kasabi.com/hometown/
So, how does this all work?
The starting point is the dbpedia data set, which contains the information stored on wikipedia.
Consider this page about Kraftwerk: http://en.wikipedia.org/wiki/Kraftwerk.
The dbpedia resource for Kraftwerk is here: http://dbpedia.org/page/Kraftwerk.
On that page, search for “dbpedia-owl:hometown”. We discover that Kraftwerk’s home town is Düsseldorf. Of course some Kraftwerk officianados know this already, but it’s a nice discovery for the rest of us.
On the Düsseldorf page we see that the geo:lat and geo:long values are supplied, so now we have latitude and longitude for Kraftwerk’s home town. Sweet!
So, what’s Kasabi and how does it help?
Kasabi allows us to create a SPARQL query against pre-loaded open datasets, one of which is, of course, dbpedia.
On the hack day, we created an API which returns kml output which we can put on a map. The API configuration is here: http://beta.kasabi.com/dataset/dbpedia-36/apis/3rn/config.
This page shows the SPARQL query we used. You can also see the xsl stylesheet used to transform the results into kml. The stylesheet is on github, here: https://raw.github.com/michaellenahan/kasabi-xsl/master/src/kml/kasabi-hackday.xsl
We use the stylesheet to merge the image and abstract into a single Description field. Thank you Tim for your help with this!
And thank you again to the Kasabi team for putting together such a great day, and helping us with the learning curve so we can start using open data for practical applications.
My unprocessed notes for the day are below.
Kasabi Hackday 2011-09-21
http://beta.kasabi.com/dataset/dbpedia-36
http://dbpedia.org/page/Radiohead
http://dbpedia.org/page/U2
A basic Sparql query.
dbpedia kasabi
http://beta.kasabi.com/dataset/dbpedia-36
http://beta.kasabi.com/dataset/dbpedia-36/apis/sparql
Sign up to the dbpedia API:
http://beta.kasabi.com/dataset/dbpedia-36/apis/sparql/roleapply/subscriber
http://beta.kasabi.com/dataset/dbpedia-36/apis/sparql
Click the link for "experimental API explorer"
http://labs.kasabi.com/explorer/sparql/dataset/dbpedia-36/apis/sparql?apikey=a36e7a3bcdd9fcebe0b32b0cef1a146912df1266
PREFIX dbpedia: <http://dbpedia.org/ontology/>
SELECT ?band WHERE {
?band a dbpedia:Band .
}
LIMIT 10
So, this gives us 10 bands.
How do we find the home town of each band?
PREFIX dbpedia: <http://dbpedia.org/ontology/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX georss: <http://www.georss.org/georss/>
SELECT ?band ?hometown ?point WHERE {
?band rdf:type dbpedia:Band ;
dbpedia:hometown ?hometown .
?hometown rdf:type dbpedia:City ;
georss:point ?point .
}
LIMIT 10
- or -
PREFIX dbpedia: <http://dbpedia.org/ontology/>
PREFIX georss: <http://www.georss.org/georss/>
SELECT ?band ?hometown ?point WHERE {
?band a dbpedia:Band ;
dbpedia:hometown ?hometown .
?hometown a dbpedia:City ;
georss:point ?point .
}
LIMIT 10
(Problem with this is inconsistent points, e.g. for Sydney)
How to put this on to a map?
go here
http://beta.kasabi.com/dataset/dbpedia-36
Create an API
Sparql Stored Procedure
Paste query
Scroll to Transforms
https://github.com/kasabi/kasabi-xsl
http://beta.kasabi.com/dataset/nhs-performance-data/apis/36z
View Configuration
http://beta.kasabi.com/dataset/nhs-performance-data/apis/36z/config
From this we get the media type:
application/vnd.google-earth.kml+xml
... and the url:
https://github.com/kasabi/kasabi-xsl/raw/master/src/kml/to-basic-placemarks.xsl
... paste these into the transforms.
"This API is currently marked as draft, and is only visible to you."
... don't publish it yet, test it first.
Need to use your apikey.
http://beta.kasabi.com/dataset/dbpedia-36/apis/3rn
http://beta.kasabi.com/dataset/dbpedia-36/apis/3rn?apikey=a36e7a3bcdd9fcebe0b32b0cef1a146912df1266
THIS DIDN'T WORK ... USE THIS INSTEAD ...
http://api.kasabi.com/dataset/dbpedia-36/apis/3rn?apikey=a36e7a3bcdd9fcebe0b32b0cef1a146912df1266
... so click publish.
http://api.kasabi.com/dataset/dbpedia-36/apis/3rn?apikey=a36e7a3bcdd9fcebe0b32b0cef1a146912df1266&output=kml
HTTP/1.1 406 Not Acceptable
Not Acceptable. output type unsupported.
edit the api
http://beta.kasabi.com/dataset/dbpedia-36/apis/3rn/edit
PREFIX dbpedia: <http://dbpedia.org/ontology/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT ?band ?hometown ?description ?lat ?long WHERE {
?band a dbpedia:Band ;
dbpedia:abstract ?description ;
dbpedia:hometown ?hometown .
?hometown a dbpedia:City ;
geo:lat ?lat ;
geo:long ?long .
}
LIMIT 10
PREFIX dbpedia: <http://dbpedia.org/ontology/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT ?band ?hometown ?description ?lat ?long WHERE {
?band a dbpedia:Band ;
dbpedia:abstract ?description ;
dbpedia:hometown ?hometown .
?hometown a dbpedia:City ;
geo:lat ?lat ;
geo:long ?long .
}
LIMIT 10
PREFIX dbpedia: <http://dbpedia.org/ontology/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?band ?hometown ?name ?description ?lat ?long WHERE {
?band a dbpedia:Band ;
#rdfs:label ?name ;
dbpedia:abstract ?description ;
dbpedia:hometown ?hometown .
?hometown a dbpedia:City ;
rdfs:label ?name ;
geo:lat ?lat ;
geo:long ?long .
FILTER(lang(?name) = "en")
}
LIMIT 10
when linking to xsl on github remember to use the raw output !!!
my working query before taking on the work michael and rick did:
PREFIX dbpedia: <http://dbpedia.org/ontology/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?band ?hometown ?name ?description ?lat ?long WHERE {
?band a dbpedia:Band ;
#rdfs:label ?name ;
dbpedia:abstract ?description ;
dbpedia:hometown ?hometown .
?hometown a dbpedia:City ;
dbpedia:country ?country ;
rdfs:label ?name ;
geo:lat ?lat ;
geo:long ?long .
#FILTER(lang(?name) = "en")
}
LIMIT 10
michael and rick's query:
PREFIX dbpedia: <http://dbpedia.org/ontology/>
PREFIX related: <http://dbpedia.org/ontology/related/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX georss: <http://www.georss.org/georss/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT DISTINCT ?band ?name ?hometown ?hometown_name ?lat ?long ?thumbnail_url WHERE
{
{
?band rdf:type dbpedia:Band ;
rdfs:label ?name ;
dbpedia:abstract ?description;
dbpedia:thumbnail ?thumbnail_url;
dbpedia:hometown ?hometown .
?hometown rdf:type dbpedia:City ;
dbpedia:country <http://dbpedia.org/resource/United_Kingdom> ;
rdfs:label ?hometown_name ;
geo:lat ?lat ;
geo:long ?long .
FILTER (lang(?name) = "en")
FILTER (lang(?hometown_name) = "en")
FILTER (lang(?description) = "en")
}
UNION
{
?band rdf:type dbpedia:Band ;
rdfs:label ?name ;
dbpedia:abstract ?description;
dbpedia:thumbnail ?thumbnail_url;
dbpedia:hometown ?hometown .
?hometown rdf:type dbpedia:City ;
related:geo <http://dbpedia.org/resource/United_Kingdom> ;
rdfs:label ?hometown_name ;
geo:lat ?lat ;
geo:long ?long .
FILTER (lang(?name) = "en")
FILTER (lang(?hometown_name) = "en")
FILTER (lang(?description) = "en")
}
}
Great write-up and thanks! Had lots of fun working with you guys