Created
January 17, 2023 23:21
-
-
Save knudmoeller/5419c2ff13f1af62bde3341213267171 to your computer and use it in GitHub Desktop.
Wikidata Query to get all planets of the solar system (and Pluto) and their moons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Planets of the solar system | |
SELECT DISTINCT ?planet ?planetLabel ?child ?childLabel | |
WHERE { | |
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } | |
{ | |
# things that are instances of planets (or subclasses thereof) | |
# and are part of the solar system (or parts of parts) | |
?planet wdt:P31/wdt:P279* wd:Q634 . | |
?planet wdt:P361+ wd:Q544 . | |
} UNION { | |
# things that stopped being planets on 2006-09-13 | |
?planet p:P31 ?statement . | |
?statement ps:P31 wd:Q634 ; | |
pq:P582 "2006-09-13T00:00:00Z"^^xsd:dateTime . | |
} | |
# and their (natural) satellites | |
?planet wdt:P398 ?child . | |
?child wdt:P31/wdt:P279* wd:Q2537 . | |
# but filter out hypothetical planets | |
FILTER NOT EXISTS {?planet wdt:P31 wd:Q1974542} | |
} | |
ORDER BY ?planetLabel ?childLabel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment