query-010a366e8a8e983e734994c4a54a5981

rq turtle/ttl

(24) Map of birth places layered by birth century: jinshi degree holdersNo.24 (2019.11.11T1546 created)

Use at

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#>
# find birth places of those who had a jinshi degree
# using birth century as layer
#defaultView:Map
SELECT  ?person ?personLabel ?image ?personDescription ?nationality ?nationalityLabel ?birth_year ?birth_place ?birth_placeLabel ?coord ?layer
WHERE {
  # define ?person as one that had academic degree (P512, or subclass of (P279), so that zhuangyuan et al. can be included) of jinshi (Q420477), and
  ?person wdt:P512/wdt:P279* wd:Q420477;
          # is instance of (P31) human (Q5)
          wdt:P31 wd:Q5
  # optional: show ?person's birth place (P19) as ?birth_place
  OPTIONAL {?person wdt:P19 ?birth_place.
             # and show ?birth_place's coordinate location (P625) as ?coord
             ?birth_place wdt:P625 ?coord}
  # optional: define ?person's birth date (P569) as ?birth_date
  OPTIONAL {?person wdt:P569 ?birth_date}
  # bind year of ?birth_date as ?birth_year
  BIND(YEAR(?birth_date) as ?birth_year)
  # use IF to classify birth years into centuries, and bind birth century as layer
  BIND(IF((?birth_year<700), "Pre-700", IF((?birth_year<800), "700-799", IF((?birth_year<900), "800-899", IF((?birth_year<1000), "900-999", IF((?birth_year<1100), "1000-1099", IF((?birth_year<1200), "1100-1199", IF((?birth_year<1300), "1200-1299", IF((?birth_year<1400), "1300-1399", IF((?birth_year<1500), "1400-1499", IF((?birth_year<1600), "1500-1599", IF((?birth_year<1700), "1600-1699", IF((?birth_year<1800), "1700-1799", "Post-1799" )))))))))))) AS ?layer)
  # optional: show ?person's nationality (P27) as ?nationality
  OPTIONAL {?person wdt:P27 ?nationality}
  # show ?person's image (P18) as ?image
  OPTIONAL {?person wdt:P18 ?image}
  # show label in simplified Chinese (zh-hans) as default, and English when no default label exists
  SERVICE wikibase:label {bd:serviceParam wikibase:language "zh-hans,en".}
}
# order layer by ?birth_year
ORDER BY ?birth_year

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?birth_date") v3("?birth_place"):::projected v6("?birth_year"):::projected v4("?coord"):::projected v8("?image"):::projected v6("?layer"):::projected v7("?nationality"):::projected v2("?person"):::projected a1((" ")) c3(["wd:Q420477"]):::iri c14(["zh-hans,en"]):::literal c12(["bd:serviceParam"]):::iri c5(["wd:Q5"]):::iri v2 --"wdt:P512"--> a1 a1 --"wdt:P279"--> c3 v2 --"wdt:P31"--> c5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P19".-> v3 v3 --"wdt:P625"--> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P569".-> v5 end bind0[/"year-from-dateTime(?birth_date)"/] v5 --o bind0 bind0 --as--o v6 bind1[/"if(?birth_year < '700^^xsd:integer','Pre-700',if(?birth_year < '800^^xsd:integer','700-799',if(?birth_year < '900^^xsd:integer','800-899',if(?birth_year < '1000^^xsd:integer','900-999',if(?birth_year < '1100^^xsd:integer','1000-1099',if(?birth_year < '1200^^xsd:integer','1100-1199',if(?birth_year < '1300^^xsd:integer','1200-1299',if(?birth_year < '1400^^xsd:integer','1300-1399',if(?birth_year < '1500^^xsd:integer','1400-1499',if(?birth_year < '1600^^xsd:integer','1500-1599',if(?birth_year < '1700^^xsd:integer','1600-1699',if(?birth_year < '1800^^xsd:integer','1700-1799','Post-1799'))))))))))))"/] v6 --o bind1 bind1 --as--o v6 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P27".-> v7 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P18".-> v8 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end