User:Geertivp/training/Wikidata Query/Object in non-existing town
In Belgium municipalities (town, city) are the only legal smallest administrative unit.
village (Q532), town (Q3957), river (Q4022), municipality (Q15284), castle (Q23413), human settlement (Q486972), municipality of Belgium (Q493522), border city (Q902814), frazione (Q1134686), district of Antwerp (Q2597772), municipality section (Q2785216), municipality seat (Q15303838), former municipality (Q19730508) are not a valid value for located in the administrative territorial entity (P131). Instead location (P276) should be used for those values.
P131 should contain the lowest legal level of administrative entity (town, city).
The below queries can feed Quickstatements to correct the error in an automated way.
Simple query for one town
editThe following query uses these:
- Items: Saint-Idesbald (Q2391194)
- Properties: located in the administrative territorial entity (P131) , location (P276) , coordinate location (P625) , instance of (P31)
Features: map (Q24515275)
# defaultView:Map
SELECT ?item ?itemLabel ?itemDescription ?geolocatie ?city ?cityLabel ?locatie ?locatieLabel ?is_een ?is_eenLabel ?layer ?article WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],nl,fr,de,en". }
?item wdt:P131 wd:Q2391194, ?city;
wikibase:sitelinks ?layer.
OPTIONAL {
?article schema:about ?item;
schema:inLanguage "nl";
schema:isPartOf <https://nl.wikipedia.org/>.
}
OPTIONAL { ?item wdt:P276 ?locatie. }
OPTIONAL { ?item wdt:P625 ?geolocatie. }
OPTIONAL { ?item wdt:P31 ?is_een. }
}
ORDER BY (?itemLabel)
All towns in a country
editThe following query uses these:
- Properties: located in the administrative territorial entity (P131) , country (P17) , instance of (P31) , location (P276) , coordinate location (P625)
Features: map (Q24515275)
# defaultView:Map
SELECT ?item ?itemLabel ?itemDescription ?instance ?instanceLabel ?geolocatie ?type ?typeLabel ?municipality ?municipalityLabel ?city ?cityLabel ?locatie ?locatieLabel ?layer ?article WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],nl,fr,de,en". }
?item wdt:P131 ?municipality;
wikibase:sitelinks ?layer;
wdt:P17 wd:Q31.
?municipality wdt:P131 ?city;
wdt:P31 wd:Q2785216, ?type.
OPTIONAL {
?article schema:about ?item;
schema:inLanguage "nl";
schema:isPartOf <https://nl.wikipedia.org/>.
}
OPTIONAL { ?item wdt:P31 ?instance. }
OPTIONAL { ?item wdt:P276 ?locatie. }
OPTIONAL { ?item wdt:P625 ?geolocatie. }
}
ORDER BY (?itemLabel)
- Caveat
- Sometimes Qnumbers appear multiple times because some properties have multiple transactions
- Sometimes located in the administrative territorial entity (P131) is not unique, leading to muliple transactions (data quality, or historical hierarchies)
Please cleanup, or process manually.
Overview of major impacted Q-numbers
editDescription - qid |
---|
municipality section (Q2785216) |
village (Q532) |
human settlement (Q486972) |
Quickstatements codes
editYou should format the result of the query into the following input file - the cells are all Q-numbers.
qid | -located in the administrative territorial entity (P131) | located in the administrative territorial entity (P131) | location (P276) |
---|---|---|---|
object | wrong municipality (municipality) | correct municipality = parent level (city) | locality = wrong municipality (municipality) |