Wednesday, December 8, 2010

Visualising Wikipedia data with Tableau, sparql and dbpedia



Geocodes and thematic mapping in SAP will be blogged later. However here as a starting point is a very quick summary of thematic mapping Japan's population by prefecture in Tableau.


Sparqling DBpedia for Japan's Population Statistics.

Check out sparql on wikipedia
Check out dbpedia on wikipedia

So DBpedia has a sparql endpoint that allowed me to extract the total population and density with the following query.

**15/03/2013 Tableau informed me that my "vizzes" will be on my own profile page very soon. So I thought I would revisit my experiment with querying Wikipedia data with SPARQL and presenting the results with tableau.

I found that I needed to change the SPARQL query as follows.
*************

PREFIX dcterms: <http://purl.org/dc/terms/>

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>

PREFIX dbpedia2: <http://dbpedia.org/property/>

SELECT ?prefecture ?lat ?long ?pop ?popt ?den ?denp

WHERE {

?prefecture dcterms:subject <http://dbpedia.org/resource/Category:Prefectures_of_Japan> .

?prefecture geo:lat ?lat .

?prefecture geo:long ?long.

OPTIONAL { ?prefecture dbpedia2:population ?pop }

OPTIONAL { ?prefecture dbpedia2:populationTotal ?popt }

OPTIONAL { ?prefecture dbpedia2:density ?den }

OPTIONAL { ?prefecture dbpedia2:populationDensityKm ?denp }

FILTER (xsd:double(?lat)).

FILTER (xsd:double(?long)).

}
**************

*original query in 2010 below will now fail to select any data.


PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>

PREFIX dbpedia2: <http://dbpedia.org/property/>

SELECT ?prefecture ?lat ?long ?pop ?popt ?den ?denp

WHERE {

?prefecture skos:subject <http://dbpedia.org/resource/Category:Prefectures_of_Japan> .

?prefecture geo:lat ?lat .

?prefecture geo:long ?long.

OPTIONAL { ?prefecture dbpedia2:population ?pop }

OPTIONAL { ?prefecture dbpedia2:populationTotal ?popt }

OPTIONAL { ?prefecture dbpedia2:density ?den }

OPTIONAL { ?prefecture dbpedia2:populationDensityKm ?denp }

FILTER (xsd:double(?lat)).

FILTER (xsd:double(?long)).

}






*2013 edit
Enter the first query above in DBpedia Virtuoso SPARQL Query From

The data needs to be tidied up (and I still have to update the prefecture names!) due to some changes of data names in the property section.

Using the SHOW ME! button in Tableau 

OK, so Tableau public is free and I can embed the data in this blog. I registered for an account cut and pasted my data above after a tidy up in Excel (you can download the data I used in the presentation). Then I hit the Show Me! button and the final presentation is here. So simple.......maybe.




No comments:

Post a Comment

Google +