Veronica
Veronica

Reputation: 290

SPARQL query to retrieve countries population density from DBPedia

Note: This question is different from SPARQL query to retrieve countries population from DBpedia. This question is about population density as understood by DBPedia itself.

How can I retrieve country population density from DBPedia?

I have tried the following, but Virtuoso endpoint returns an empty result set:

PREFIX p: <http://dbpedia.org/property/>
SELECT DISTINCT ?name ?populationDensity
WHERE {
    ?country a dbpedia-owl:Country . 
    ?country rdfs:label ?name . 
    ?country p:populationDensity ?populationDensity . }

Upvotes: 2

Views: 799

Answers (1)

Spork
Spork

Reputation: 1651

Your current query returns an empty table because there is no ?country that fulfills your query that has the rdf:type dbpedia-owl:Country (represented by 'a'). Check that with this query.

To find the list of rdf:type's that the set of data that does use your populationDensity you could use this query. Following that lead you can just check all properties for Portugal and find that it does have populationDensity, but not the one you used.

This works:

PREFIX dbpedia-ont-PP: <http://dbpedia.org/ontology/PopulatedPlace/>
SELECT DISTINCT ?country ?populationDensity
WHERE {
    ?country a dbpedia-owl:Country .
    ?country dbpedia-ont-PP:populationDensity ?populationDensity . 
}

Upvotes: 3

Related Questions