Search code examples
sparqlsemanticsontologydbpedia

Get geographical coordinates of a particular place from DbPedia


I need to get the co-ordinates of some particular places from DbPedia. For the same I am using following snippet:

PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> 
PREFIX dbo: <http://dbpedia.org/ontology/> 
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
  SELECT * WHERE {
  ?x foaf:name 'Mumbai'.
  ?x dbo:Place 'Mumbai'.
  ?x geo:lat ?lat .
  ?x geo:long ?long .
  } 

On running at http://dbpedia.org/sparql, it returns an empty page. I think I didn't put the name of place in the correct way. Can anyone help me to find the issue


Solution

  • Have a look at the N3/TTL serialization of the data for Mumbai. Note that the foaf:name value has a language tag: foaf:name "Mumbai"@en. You need to use "Mumbai"@en, with the language tag, in the query. Additionally, doing dbo:Place 'Mumbai' doesn't make any sense. You might instead want to ask for things which are dbpedia-owl:Places. You'd end up with a query like:

    select * {
      ?mumbai a dbpedia-owl:Place ;
              foaf:name "Mumbai"@en ;
              geo:lat ?lat ;
              geo:long ?long
    }
    

    SPARQL Results