I want to query the neighbours to a country with SPARQL from Wikidata like this:
SELECT ?country ?countryLabel WHERE {
?country wdt:P47 wd:Q183 .
FILTER NOT EXISTS{ ?country wdt:P576 ?date } # don't count dissolved country - at least filters German Democratic Republic
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
My issue is that e.g. in this example for neighbours of germany there are still countries shown which does not exist anymore like:
- Kingdom of Denmark or
- Saarland.
Already tried
I could already reduce the number by the FILTER
statement.
Question
- How to make the statement to reduce it to 9 countries?
- (also dividing in land boarder and sea boarder would be great)
Alternative
- Filtering at this API would be also fine for me https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q35
- a database or lists or prepared HashMaps whatever with all countries of the world with neighbours