query-2c7e979528c1cdb1c2d54fda38c42305
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 bd: <http://www.bigdata.com/rdf#>
#defaultView:Map
#title:UK rivers that enter the sea
SELECT DISTINCT ?river ?riverLabel ?sea ?seaLabel ?coord WHERE
{
?another_river wdt:P17 wd:Q145. # ?another_river is in the UK
?another_river wdt:P403|wdt:P201 ?sea . # has a mouth of a watercourse or lake outflow
# at this point ?sea could still be another watercourse
# DESIGN PATTERN
# define a ?sea as a sea by...
FILTER NOT EXISTS {?sea wdt:P31/wdt:P279* wd:Q355304 . # excluding watercourses
FILTER NOT EXISTS {?sea wdt:P31 wd:Q47053. } # except when they're an estuary
FILTER NOT EXISTS {?sea wdt:P31 wd:Q1210950. } # or a channel
# by nesting FILTER NOT EXIST clauses
# within a FILTER NOT EXIST clause
}
FILTER NOT EXISTS {?sea wdt:P31/wdt:P279* wd:Q23397 . } # Exclude lakes
?sea ^wdt:P403|^wdt:P201 ?river. # ?sea is at the mouth/outflow of the ?river
?river wdt:P17 wd:Q145. # ?river is in the UK
?river wdt:P625 ?coord. # get ?river coordinates
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?another_river")
v4("?coord"):::projected
v3("?river"):::projected
v1("?sea"):::projected
a2((" "))
a1((" "))
c3(["wd:Q23397"]):::iri
c5(["wd:Q47053"]):::iri
c4(["wd:Q1210950"]):::iri
c6(["wd:Q355304"]):::iri
c13(["bd:serviceParam"]):::iri
c15(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c8(["wd:Q145"]):::iri
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0v1 --"wdt:P31"--> e0a1
e0a1 --"wdt:P279"--> e0c3
e0v1("?sea"):::projected
e0a1((" ")):::projected
e0c3(["wd:Q23397"]):::iri
end
f0--EXISTS--> f0e0
f0 --> v1
f0 --> c1
f0 --> a1
f0 --> c2
f0 --> c3
v1 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c3
f1[["not "]]
subgraph f1e1["Exists Clause"]
e1f0[["not "]]
subgraph e1f0e1e0["Exists Clause"]
e1e0v1 --"wdt:P31"--> e1e0c2
e1e0v1("?sea"):::projected
e1e0c2(["wd:Q1210950"]):::iri
end
e1f0--EXISTS--> e1f0e1e0
e1f0 --> e1v1
e1f0 --> e1c1
e1f0 --> e1c2
e1v1 --"wdt:P31"--> e1c2
e1f1[["not "]]
subgraph e1f1e1e1["Exists Clause"]
e1e1v1 --"wdt:P31"--> e1e1c2
e1e1v1("?sea"):::projected
e1e1c2(["wd:Q47053"]):::iri
end
e1f1--EXISTS--> e1f1e1e1
e1f1 --> e1v1
e1f1 --> e1c1
e1f1 --> e1c3
e1v1 --"wdt:P31"--> e1c3
e1v1 --"wdt:P31"--> e1a1
e1a1 --"wdt:P279"--> e1c5
e1v1("?sea"):::projected
e1a1((" ")):::projected
e1c5(["wd:Q355304"]):::iri
e1c3(["wd:Q47053"]):::iri
e1c2(["wd:Q1210950"]):::iri
end
f1--EXISTS--> f1e1
f1 --> v1
f1 --> c1
f1 --> c4
f1 --> c5
f1 --> a2
f1 --> c2
f1 --> c6
f2[["not "]]
subgraph f2e2["Exists Clause"]
e2v1 --"wdt:P31"--> e2c2
e2v1("?sea"):::projected
e2c2(["wd:Q1210950"]):::iri
end
f2--EXISTS--> f2e2
f2 --> v1
f2 --> c1
f2 --> c4
v1 --"wdt:P31"--> c4
f3[["not "]]
subgraph f3e3["Exists Clause"]
e3v1 --"wdt:P31"--> e3c2
e3v1("?sea"):::projected
e3c2(["wd:Q47053"]):::iri
end
f3--EXISTS--> f3e3
f3 --> v1
f3 --> c1
f3 --> c5
v1 --"wdt:P31"--> c5
v1 --"wdt:P31"--> a2
a2 --"wdt:P279"--> c6
v2 --"wdt:P17"--> c8
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P201"--> v1
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P403"--> v1
end
union0r <== or ==> union0l
end
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v3 --"wdt:P201"--> v1
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v3 --"wdt:P403"--> v1
end
union1r <== or ==> union1l
end
v3 --"wdt:P17"--> c8
v3 --"wdt:P625"--> v4
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c13 --"wikibase:language"--> c15
end