query-b9101f6b6ef4a5480c4aeab849f3f03f

rq turtle/ttl

(23) Map of residences and birth/death places: Water Margin charactersNo.23 (2019.11.11T0947 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#>
# show Water Margin characters' residences and birth/death places on map
# with ?edgeLabel as layer
#defaultView:Map{"layer":"?edgeLabel"}
### Note: 1. The dot on map does not reflect the number of persons who were born or died there, i.e.,
### no matter how many persons share a same birth/death place, the dot on that place remains the same size.
### 2. If "layer" is not used, clicking a multi-person place will show options of each person, while
### if "layer" is used (as in this query), clicking a multi-person place will only show one person's information.
# show ?person's description by using ?personDescription (my first time showing description)
SELECT DISTINCT ?person ?nick_name ?personLabel ?image ?personDescription ?groupLabel ?edgeLabel ?place ?placeLabel ?coord 
WHERE {
  # define ?person as one that is present in work (P1441) Water Margin (Q70827), and
  ?person wdt:P1441 wd:Q70827;
          # is instance of (P31) or any subclass of (P279) fictional character (Q95074)
          wdt:P31/wdt:P279* wd:Q95074.
  # optional: show ?person's birth place (P19) or residence (P551) or death place (P20) as ?place
  OPTIONAL {?person (wdt:P19|wdt:P551|wdt:P20) ?place
             # optional: show ?place's coordinate location (P625) as ?coord
             ### Note: show ?coord as optional so that those places with no value or unknown value 
             ### can also be shown in table, although not on map
            OPTIONAL {?place wdt:P625 ?coord}
            # To avoid showing any other relation
            # define ?relation as birth place (P19) or residence (P551) or death place (P20) 
            VALUES ?relation {wdt:P19 wdt:P551 wdt:P20}
            # ?relation is from ?person to ?place
            ?person ?relation ?place.
            # show ?relation on graph edges
           ?edge wikibase:directClaim ?relation;
               a wikibase:Property}
  # show ?person's nick name (P1449) as ?nick_name
  OPTIONAL {?person wdt:P1449 ?nick_name}
  # optional: show ?person's member_of (P463) as ?group
  OPTIONAL {?person wdt:P463 ?group}
  # optional: 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".}
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?coord"):::projected v4("?edge") v7("?group") v8("?image"):::projected v6("?nick_name"):::projected v1("?person"):::projected v2("?place"):::projected v3("?relation") a1((" ")) c11(["wikibase:Property"]):::iri c19(["zh-hans,en"]):::literal c5(["wd:Q95074"]):::iri c2(["wd:Q70827"]):::iri c17(["bd:serviceParam"]):::iri v1 --"wdt:P1441"--> c2 v1 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v1 -."wdt:P20".-> v2 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P551"--> v2 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P19"--> v2 end union0r <== or ==> union0l end bind0[/VALUES ?relation/] bind0-->v3 bind00(["wdt:P19"]) bind00 --> bind0 bind01(["wdt:P551"]) bind01 --> bind0 bind02(["wdt:P20"]) bind02 --> bind0 v1 -->v3--> v2 v4 --"wikibase:directClaim"--> v3 v4 --"a"--> c11 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P625".-> v5 end end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P1449".-> v6 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P463".-> v7 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P18".-> v8 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c17 --"wikibase:language"--> c19 end