query-d5831fc3c98df053a06172e4d648076f
(54) Twenty-Six Histories: map of capitals and formation locations of countriesNo.54 (2020.10.10T1547 created)
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#>
# capitals and formation locations of countries in the Twenty-Six Histories
# viewed as map, layered by ?edgeLabel (replaceable by ?bookLabel or ?genreLabel)
#defaultView:Map{"layer":"?edgeLabel"}
# also viewable as table, graph, and image grid
SELECT DISTINCT ?country ?countryLabel ?countryDescription ?image ?bookLabel ?volume ?partLabel ?genreLabel ?start ?end ?place ?placeLabel ?coord ?edgeLabel
WHERE {
# define ?book specifically as:
### Note: Certain books can be removed from the list so that a map for one or some specific books can be generated.
# Records of the Grand Historian (Q272530), Book of Han (Q846905), Book of the Later Han (Q430428), Records of the Three Kingdoms (Q247318), Book of Jin (Q1154753)
# Book of Song (Q1143142), Book of Southern Qi (Q1192857), Book of Liang (Q1285767), Book of Chen (Q1275744), Book of Wei (Q1269357)
VALUES ?book {wd:Q272530 wd:Q846905 wd:Q430428 wd:Q247318 wd:Q1154753 wd:Q1143142 wd:Q1192857 wd:Q1285767 wd:Q1275744 wd:Q1269357
# Book of Northern Qi (Q1247505), Book of Zhou (Q1285731), Book of Sui (Q1156924), History of Southern Dynasties (Q1137686), History of Northern Dynasties (Q1188548)
# Old Book of Tang (Q1146980), New Book of Tang (Q386073), Old History of the Five Dynasties (Q1333316), New History of the Five Dynasties (Q919488), History of Song (Q1147260)
wd:Q1247505 wd:Q1285731 wd:Q1156924 wd:Q1137686 wd:Q1188548 wd:Q1146980 wd:Q386073 wd:Q1333316 wd:Q919488 wd:Q1147260
# History of Liao (Q1188539), History of Jin (Q637035), History of Yuan (Q1345223), History of Ming (Q28763)
# New History of Yuan (Q1053256), Draft History of Qing (Q1374339)
wd:Q1188539 wd:Q637035 wd:Q1345223 wd:Q28763 wd:Q1053256 wd:Q1374339}
# optional: show ?part, which is part of (P361) or published in (P1433) [ZeroOrMorePath (*)] ?book
OPTIONAL {?part (wdt:P361|wdt:P1433)* ?book;
# ?part's main subject (P921) is ?country
wdt:P921 ?country.
# ?country is instance of (P31) subclass of (P279) [ZeroOrMorePath (*)] historical country (Q3024240)
?country wdt:P31/wdt:P279* wd:Q3024240
# optional: show ?part's volume (P478) as ?volume
OPTIONAL {?part wdt:P478 ?volume}
# optional: show ?part's genre (P136) as ?genre
OPTIONAL {?part wdt:P136 ?genre}
# optional: show ?country's image (P18) as ?image
OPTIONAL {?country wdt:P18 ?image}
# optional: show ?country's inception (P571) as ?start
OPTIONAL {?country wdt:P571 ?start}
# optional: show ?country's dissolution (P576) as ?end
OPTIONAL {?country wdt:P576 ?end}
# optional: show ?country's capital (P36) or location of formation (P740) as ?place
### Note: One property can be removed so that a map for the other property can be generated when layered by ?bookLabel or ?genreLabel.
OPTIONAL {?country (wdt:P36|wdt:P740) ?place
# to avoid showing any other relation
# define ?relation as capital (P36) or location of formation (P740)
VALUES ?relation {wdt:P36 wdt:P740}
# ?relation is from ?country to ?place
?country ?relation ?place.
# get ?relation's property label and allow it to appear on graph edge
?edge wikibase:directClaim ?relation;
a wikibase:Property
# optional: show ?place's coordinate location (P625) as ?coord
OPTIONAL {?place wdt:P625 ?coord} } }
# show label in auto language as default, and English when no default label exists
SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}
# order layer by ?edgeLabel (replaceable by ?bookLabel or ?genreLabel)
ORDER BY ?edgeLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?book")
v13("?coord"):::projected
v4("?country"):::projected
v12("?edge")
v1("?edgeLabel"):::projected
v9("?end"):::projected
v6("?genre")
v7("?image"):::projected
v3("?part")
v10("?place"):::projected
v11("?relation")
v8("?start"):::projected
v5("?volume"):::projected
a1((" "))
c16(["wikibase:Property"]):::iri
c6(["wd:Q3024240"]):::iri
c19(["bd:serviceParam"]):::iri
c21(["#91;AUTO_LANGUAGE#93;,en"]):::literal
bind0[/VALUES ?book/]
bind0-->v2
bind00(["wd:Q272530"])
bind00 --> bind0
bind01(["wd:Q846905"])
bind01 --> bind0
bind02(["wd:Q430428"])
bind02 --> bind0
bind03(["wd:Q247318"])
bind03 --> bind0
bind04(["wd:Q1154753"])
bind04 --> bind0
bind05(["wd:Q1143142"])
bind05 --> bind0
bind06(["wd:Q1192857"])
bind06 --> bind0
bind07(["wd:Q1285767"])
bind07 --> bind0
bind08(["wd:Q1275744"])
bind08 --> bind0
bind09(["wd:Q1269357"])
bind09 --> bind0
bind010(["wd:Q1247505"])
bind010 --> bind0
bind011(["wd:Q1285731"])
bind011 --> bind0
bind012(["wd:Q1156924"])
bind012 --> bind0
bind013(["wd:Q1137686"])
bind013 --> bind0
bind014(["wd:Q1188548"])
bind014 --> bind0
bind015(["wd:Q1146980"])
bind015 --> bind0
bind016(["wd:Q386073"])
bind016 --> bind0
bind017(["wd:Q1333316"])
bind017 --> bind0
bind018(["wd:Q919488"])
bind018 --> bind0
bind019(["wd:Q1147260"])
bind019 --> bind0
bind020(["wd:Q1188539"])
bind020 --> bind0
bind021(["wd:Q637035"])
bind021 --> bind0
bind022(["wd:Q1345223"])
bind022 --> bind0
bind023(["wd:Q28763"])
bind023 --> bind0
bind024(["wd:Q1053256"])
bind024 --> bind0
bind025(["wd:Q1374339"])
bind025 --> bind0
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v3 -."wdt:P1433".-> v2
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v3 --"wdt:P361"--> v2
end
union0r <== or ==> union0l
end
v3 --"wdt:P921"--> v4
v4 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c6
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P478".-> v5
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P136".-> v6
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P18".-> v7
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P571".-> v8
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P576".-> v9
end
subgraph optional6["(optional)"]
style optional6 fill:#bbf,stroke-dasharray: 5 5;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v4 -."wdt:P740".-> v10
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v4 --"wdt:P36"--> v10
end
union1r <== or ==> union1l
end
bind1[/VALUES ?relation/]
bind1-->v11
bind10(["wdt:P36"])
bind10 --> bind1
bind11(["wdt:P740"])
bind11 --> bind1
v4 -->v11--> v10
v12 --"wikibase:directClaim"--> v11
v12 --"a"--> c16
subgraph optional7["(optional)"]
style optional7 fill:#bbf,stroke-dasharray: 5 5;
v10 -."wdt:P625".-> v13
end
end
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c19 --"wikibase:language"--> c21
end