alkey
alkey

Reputation: 1046

Querying distance units in Sparql - Wikidata example

I would like to know the simplest way to handle units of distance in Sparql. In this Wikidata example I would like to select all the mountains over 8000m; however when I run the text below it also includes all of the mountains over 8000ft. Is it possible to specify that the units I am interested is meters, and for the mountains that are specified in feet, is a conversion to meters necessary?

#Mountains Over 8000m
SELECT ?mountainLabel ?height 
WHERE 
{
  ?mountain wdt:P31 wd:Q8502. 
  ?mountain wdt:P2044 ?height.

  FILTER(8000 <= ?height)

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en, de". }
}

Upvotes: 0

Views: 398

Answers (1)

John Skiles Skinner
John Skiles Skinner

Reputation: 2028

The psn namespace prefix is used to normalize units of measure. Your query can look like this:

SELECT ?mountainLabel ?height 
WHERE 
{
  ?mountain wdt:P31 wd:Q8502. 
  ?mountain p:P2044/psn:P2044/wikibase:quantityAmount ?height .
  FILTER(8000 <= ?height)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en, de". }
}

Upvotes: 2

Related Questions