query-61bf542d9b407d9b966b28ec2e0e2300
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#villages without wikidata in OSM in a district with mandal and village string as match element
#When changing district, ensure the change is made in the MINUS subquery also
#defaultView:Map
SELECT DISTINCT ?censuscode ?villagematch ?wd_label_village ?wd_label_village_te ?wd_qid_village ?wd_loc_village ?wd_label_mandal WHERE {
?village (wdt:P131*) wd:Q110714853;
wdt:P131 ?wd_mandal;
(wdt:P31/(wdt:P279*)) wd:Q56436498;
wdt:P625 ?wd_loc_village.
OPTIONAL { ?village wdt:P5578 ?censuscode. }
MINUS {
?village (wdt:P131*) wd:Q110714853;
(wdt:P31/(wdt:P279*)) wd:Q56436498;
wdt:P625 _:b4.
SERVICE <https://sophox.org/sparql> {
?osmid <https://wiki.openstreetmap.org/wiki/Key:wikidata> ?village;
<https://www.openstreetmap.org/meta/loc> ?osmloc.
}
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en".
?village rdfs:label ?wd_label_village.
?wd_mandal rdfs:label ?wd_label_mandal.
}
OPTIONAL {
?village rdfs:label ?wd_label_village_te.
FILTER((LANG(?wd_label_village_te)) = "te")
}
BIND(STR(?village) AS ?wdstring1)
BIND(STRAFTER(?wdstring1, "http://www.wikidata.org/entity/") AS ?wd_qid_village)
BIND(STR(?wd_mandal) AS ?wdstring2)
BIND(STRAFTER(?wdstring2, "http://www.wikidata.org/entity/") AS ?wd_qid_mandal)
BIND(CONCAT(?wd_qid_mandal, " ", ?wd_label_village) AS ?villagematch)
}
ORDER BY (?censuscode)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?censuscode"):::projected
v6("?osmid")
v7("?osmloc")
v3("?village")
v14("?villagematch"):::projected
v9("?wd_label_mandal"):::projected
v8("?wd_label_village"):::projected
v2("?wd_label_village_te"):::projected
v5("?wd_loc_village"):::projected
v4("?wd_mandal")
v13("?wd_qid_mandal")
v11("?wd_qid_village"):::projected
v10("?wdstring1")
v12("?wdstring2")
a3((" "))
a1((" "))
a2((" "))
c3(["wd:Q110714853"]):::iri
c15(["en"]):::literal
c13(["bd:serviceParam"]):::iri
c6(["wd:Q56436498"]):::iri
v3 --"wdt:P131"--> c3
v3 --"wdt:P131"--> v4
v3 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c6
v3 --"wdt:P625"--> v5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P5578".-> v1
end
subgraph minus0["MINUS"]
style minus0 stroke-width:6px,fill:pink,stroke:red;
v3 --"wdt:P131"--> c3
v3 --"wdt:P31"--> a2
a2 --"wdt:P279"--> c6
v3 --"wdt:P625"--> a3
subgraph s1["https://sophox.org/sparql"]
style s1 stroke-width:4px;
v6 --https://wiki.openstreetmap.org/wiki/Key:wikidata--> v3
v6 --https://www.openstreetmap.org/meta/loc--> v7
end
end
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c13 --"wikibase:language"--> c15
v3 --"rdfs:label"--> v8
v4 --"rdfs:label"--> v9
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."rdfs:label".-> v2
end
bind1[/"str(?village)"/]
v3 --o bind1
bind1 --as--o v10
bind2[/"substring-after(?wdstring1,'http://www.wikidata.org/entity/')"/]
v10 --o bind2
bind2 --as--o v11
bind3[/"str(?wd_mandal)"/]
v4 --o bind3
bind3 --as--o v12
bind4[/"substring-after(?wdstring2,'http://www.wikidata.org/entity/')"/]
v12 --o bind4
bind4 --as--o v13
bind5[/"concat(?wd_qid_mandal,' ',?wd_label_village)"/]
v13 --o bind5
v8 --o bind5
bind5 --as--o v14