query-676b4869bf06b8bd4330eba6a9513346
Average distance between birthplace and deathplace by yearHi, I need some help to refine this query :
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
#Average distance between birthplace and deathplace by year
#defaultView:LineChart
SELECT ?year ?average WHERE {
SELECT ?year (AVG(?dist) AS ?average) WHERE {
?person wdt:P27 wd:Q142 ; wdt:P19 ?birthplace ; wdt:P20 ?deathplace ; wdt:P570 ?date .
?birthplace wdt:P625 ?coordBirth .
?deathplace wdt:P625 ?coordDeath .
BIND(geof:distance(?coordBirth, ?coordDeath) as ?dist)
BIND(year(?date) as ?year )
FILTER(?year > 1000 )
}
GROUP BY ?year
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v9("?average"):::projected
v3("?birthplace")
v6("?coordBirth")
v7("?coordDeath")
v5("?date")
v4("?deathplace")
v8("?dist")
v2("?person")
v9("?year"):::projected
c3(["wd:Q142"]):::iri
f0[["?year > '1000^^xsd:integer'"]]
f0 --> v9
v2 --"wdt:P27"--> c3
v2 --"wdt:P19"--> v3
v2 --"wdt:P20"--> v4
v2 --"wdt:P570"--> v5
v3 --"wdt:P625"--> v6
v4 --"wdt:P625"--> v7
bind1[/"http://www.opengis.net/def/function/geosparql/distance(?coordBirth,?coordDeath)"/]
v6 --o bind1
v7 --o bind1
bind1 --as--o v8
bind2[/"year-from-dateTime(?date)"/]
v5 --o bind2
bind2 --as--o v9
bind4[/"average(?dist)"/]
v8 --o bind4
bind4 --as--o v9