query-0337442e36e2a6d6a8d250343b6908a7
Events happened in a certain geo box
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#>
SELECT ?item ?itemLabel ?location ?pointInTime WHERE {
# Define the modern country (e.g., Russia as wd:Q159)
VALUES ?modernCountry { wd:Q29 }
# Get the modern country's bounding points
?modernCountry wdt:P1332 ?northernPoint .
?modernCountry wdt:P1333 ?southernPoint .
?modernCountry wdt:P1334 ?easternPoint .
?modernCountry wdt:P1335 ?westernPoint .
# Subquery to fetch a limited sample of battle items (would time out otherwise for some countries with lots of items)
{
SELECT ?item WHERE {
?item wdt:P31/wdt:P279* wd:Q178561. # Filter for instances of battles
}
LIMIT 5000
}
# Use these points to define the bounding box
SERVICE wikibase:box {
?item wdt:P625 ?location .
bd:serviceParam wikibase:cornerWest ?westernPoint .
bd:serviceParam wikibase:cornerEast ?easternPoint .
bd:serviceParam wikibase:cornerNorth ?northernPoint .
bd:serviceParam wikibase:cornerSouth ?southernPoint .
}
OPTIONAL { ?item wdt:P585 ?pointInTime. }
# Fetch labels for the final result set
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;
v4("?easternPoint")
v6("?item"):::projected
v7("?location"):::projected
v1("?modernCountry")
v2("?northernPoint")
v8("?pointInTime"):::projected
v3("?southernPoint")
v5("?westernPoint")
a1((" "))
c10(["bd:serviceParam"]):::iri
c7(["wd:Q178561"]):::iri
c18(["#91;AUTO_LANGUAGE#93;,en"]):::literal
bind0[/VALUES ?modernCountry/]
bind0-->v1
bind00(["wd:Q29"])
bind00 --> bind0
v1 --"wdt:P1332"--> v2
v1 --"wdt:P1333"--> v3
v1 --"wdt:P1334"--> v4
v1 --"wdt:P1335"--> v5
v6 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c7
subgraph s1["http://wikiba.se/ontology#box"]
style s1 stroke-width:4px;
v6 --"wdt:P625"--> v7
c10 --"wikibase:cornerWest"--> v5
c10 --"wikibase:cornerEast"--> v4
c10 --"wikibase:cornerNorth"--> v2
c10 --"wikibase:cornerSouth"--> v3
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v6 -."wdt:P585".-> v8
end
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c10 --"wikibase:language"--> c18
end