0

I need to retrieve a list of top ten highest points on Earth using SPARQL on Wikidata

SELECT ?mountain ?mountainLabel WHERE {
  ?mountain wdt:P31 wd:Q8502.
  OPTIONAL { ?mountain wdt:P610 ?highest_point. }  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
LIMIT 10

I expect the output to be mountain QIDs in the first column, names of the mountains in the second column, and heights in the third column

rickhg12hs
  • 10,638
  • 6
  • 24
  • 42
Baris
  • 1
  • 2
    So what is your question? – Gilles-Antoine Nys Apr 04 '19 at 13:05
  • I'm pretty sure this has been asked and answered before or it was in the Wikidata examples – UninformedUser Apr 04 '19 at 13:07
  • Ah, here we go: https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples#Mountains – UninformedUser Apr 04 '19 at 13:07
  • I don't have a answer, that is why I am asking for help. – Baris Apr 04 '19 at 13:08
  • 1
    `SELECT DISTINCT ?item ?mountainLabel ?elev { ?mountain wdt:P31 wd:Q8502 ; p:P625/psv:P625/wikibase:geoGlobe wd:Q2 ; wdt:P2044 ?elev SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . } } ORDER BY DESC(?elev) limit 10` – UninformedUser Apr 04 '19 at 13:13
  • `order by` takes ages because there are `309110` mountains in the dataset and currently the endpoints seems to be slow. – UninformedUser Apr 04 '19 at 13:17
  • Apparently, some mountains have elevation values in different units, thus, to stick e.g. to meters you should do: `SELECT DISTINCT ?item ?elev ?unit{ ?item wdt:P31 wd:Q8502 ; p:P625/psv:P625/wikibase:geoGlobe wd:Q2 ; p:P2044/psv:P2044 ?valuenode. ?valuenode wikibase:quantityAmount ?elev ; wikibase:quantityUnit wd:Q11573 #SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . } } ORDER BY DESC(?elev) limit 10` – UninformedUser Apr 05 '19 at 08:00

0 Answers0