query-9a93a75ca24f08e2b2cd67099bd47c8e
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 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#>
SELECT ?item ?itemLabel ?epicenter ?time (SUM(?population) AS ?total_population) (SAMPLE(?place) AS ?sample_place) WHERE {
{
SELECT * {
VALUES ?item {wd:Q38982786}. # Q38982786 is the Wikidata identifier for the 2017 Chiapas earthquake; change this value if you want to run the query for another earthquake
?item wdt:P625 ?epicenter.
OPTIONAL {?item wdt:P585 ?time .}
SERVICE wikibase:around {
?place wdt:P625 ?location .
bd:serviceParam wikibase:center ?epicenter .
bd:serviceParam wikibase:radius 150 .
} .
}
}.
?place p:P1082 [ ps:P1082 ?population; pq:P585 ?date ] .
FILTER( ?time >= ?date ) .
MINUS {
?place p:P1082/pq:P585 ?date2 .
FILTER( ?time >= ?date2 && ?date2 > ?date ) .
} .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .
?item rdfs:label ?itemLabel .
} .
} GROUP BY ?item ?itemLabel ?epicenter ?time
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?date")
v8("?date2")
v4("?epicenter"):::projected
v3("?item"):::projected
v9("?itemLabel"):::projected
v6("?location")
v5("?place"):::projected
v7("?population"):::projected
v11("?sample_place")
v1("?time"):::projected
v10("?total_population")
a1((" "))
a2((" "))
c7(["150^^xsd:integer"]):::literal
c4(["bd:serviceParam"]):::iri
c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["?time >= ?date"]]
f0 --> v1
f0 --> v2
bind1[/VALUES ?item/]
bind1-->v3
bind10(["wd:Q38982786"])
bind10 --> bind1
v3 --"p:direct/P625"--> v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P585".-> v1
end
subgraph s1["http://wikiba.se/ontology#around"]
style s1 stroke-width:4px;
v5 --"p:direct/P625"--> v6
c4 --"wikibase:center"--> v4
c4 --"wikibase:radius"--> c7
end
a1 --"p:statement/P1082"--> v7
a1 --"p:qualifier/P585"--> v2
v5 --"p:P1082"--> a1
subgraph minus2["MINUS"]
style minus2 stroke-width:6px,fill:pink,stroke:red;
f3[["?time >= ?date2?date2 > ?date"]]
f3 --> v1
f3 --> v8
f3 --> v2
v5 --"p:P1082"--> a2
a2 --"p:qualifier/P585"--> v8
end
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c4 --"wikibase:language"--> c13
v3 --"rdfs:label"--> v9
end
bind6[/"sum(?population)"/]
v7 --o bind6
bind6 --as--o v10
bind7[/"sample(?place)"/]
v5 --o bind7
bind7 --as--o v11