query-96d185775b5a80c0c3a45f101633bdc9
Borders of country A and B
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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Map
select
?item ?itemLabel
(SAMPLE(?coor) as ?coor)
(group_concat(DISTINCT ?natureLabel) as ?NATURE)
(group_concat(DISTINCT ?paysLabel; separator=", ") as ?PAYS)
(group_concat(DISTINCT ?partiedeLabel; separator=" // ") AS ?partiedeL)
(group_concat(DISTINCT ?adjacentLabel; separator=" // ") AS ?adjacentL)
WHERE
{
{ SELECT ?item ?itemLabel ?nature ?natureLabel ?coor ?pays ?paysLabel ?partiede ?partiedeLabel ?adjacent ?adjacentLabel
WHERE
{
?item wdt:P31/wdt:P279* wd:Q757292 .
?item wdt:P361 wd:Q119515.#border of country A AND B
OPTIONAL { ?item wdt:P3032 ?adjacent}
MINUS { ?item (wdt:P31/wdt:P279*) wd:Q4366834. } # exclude cours d'eau
MINUS { ?item (wdt:P31/wdt:P279*) wd:Q218719. } # exclude contr^le frontalier
MINUS { ?item wdt:P361 wd:Q3089219. } #Remove maritime borders
MINUS { ?item (wdt:P31/wdt:P279*) wd:Q1402443. } # exclude railway station border
MINUS { ?item wdt:P361 wd:Q1292279. } #Remove political borders (not international)
MINUS { ?item wdt:P361 wd:Q67457910. } #Remove municipal borders
MINUS { ?item wdt:P361 wd:Q67218438. } #Remove air borders
MINUS { ?item wdt:P576 _:b2. }
MINUS { ?item p:P361 [ps:P361 wd:Q1292279 ; pq:P576 ?P576 ] . }
?item wdt:P31 ?nature.
?item wdt:P17 ?pays.
OPTIONAL { ?item wdt:P361 ?partiede }
OPTIONAL { ?item wdt:P625 ?coor }
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en" }
} #
} #
} group by ?item ?itemLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v12("?NATURE")
v3("?P576")
v13("?PAYS")
v2("?adjacent")
v15("?adjacentL")
v11("?adjacentLabel"):::projected
v12("?coor"):::projected
v1("?item"):::projected
v4("?nature")
v8("?natureLabel"):::projected
v6("?partiede")
v14("?partiedeL")
v10("?partiedeLabel"):::projected
v5("?pays")
v9("?paysLabel"):::projected
a5((" "))
a1((" "))
a2((" "))
a3((" "))
a4((" "))
a6((" "))
c8(["wd:Q218719"]):::iri
c3(["wd:Q757292"]):::iri
c21(["bd:serviceParam"]):::iri
c5(["wd:Q119515"]):::iri
c23(["fr,en"]):::literal
c9(["wd:Q3089219"]):::iri
c12(["wd:Q67457910"]):::iri
c7(["wd:Q4366834"]):::iri
c11(["wd:Q1292279"]):::iri
c10(["wd:Q1402443"]):::iri
c13(["wd:Q67218438"]):::iri
v1 --"p:direct/P31"--> a1
a1 --"p:direct/P279"--> c3
v1 --"p:direct/P361"--> c5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:direct/P3032".-> v2
end
subgraph minus0["MINUS"]
style minus0 stroke-width:6px,fill:pink,stroke:red;
v1 --"p:direct/P31"--> a2
a2 --"p:direct/P279"--> c7
end
subgraph minus1["MINUS"]
style minus1 stroke-width:6px,fill:pink,stroke:red;
v1 --"p:direct/P31"--> a3
a3 --"p:direct/P279"--> c8
end
subgraph minus2["MINUS"]
style minus2 stroke-width:6px,fill:pink,stroke:red;
v1 --"p:direct/P361"--> c9
end
subgraph minus3["MINUS"]
style minus3 stroke-width:6px,fill:pink,stroke:red;
v1 --"p:direct/P31"--> a4
a4 --"p:direct/P279"--> c10
end
subgraph minus4["MINUS"]
style minus4 stroke-width:6px,fill:pink,stroke:red;
v1 --"p:direct/P361"--> c11
end
subgraph minus5["MINUS"]
style minus5 stroke-width:6px,fill:pink,stroke:red;
v1 --"p:direct/P361"--> c12
end
subgraph minus6["MINUS"]
style minus6 stroke-width:6px,fill:pink,stroke:red;
v1 --"p:direct/P361"--> c13
end
subgraph minus7["MINUS"]
style minus7 stroke-width:6px,fill:pink,stroke:red;
v1 --"p:direct/P576"--> a5
end
subgraph minus8["MINUS"]
style minus8 stroke-width:6px,fill:pink,stroke:red;
a6 --"p:statement/P361"--> c11
a6 --"p:qualifier/P576"--> v3
v1 --"p:P361"--> a6
end
v1 --"p:direct/P31"--> v4
v1 --"p:direct/P17"--> v5
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:direct/P361".-> v6
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:direct/P625".-> v12
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c21 --"wikibase:language"--> c23
end
bind14[/"sample(?coor)"/]
v12 --o bind14
bind14 --as--o v12
bind15[/"?natureLabel"/]
v8 --o bind15
bind15 --as--o v12
bind16[/"?paysLabel"/]
v9 --o bind16
bind16 --as--o v13
bind17[/"?partiedeLabel"/]
v10 --o bind17
bind17 --as--o v14
bind18[/"?adjacentLabel"/]
v11 --o bind18
bind18 --as--o v15