query-ac915d9c366d1a063affd65c2105b48d

rq turtle/ttl

Map and list of municipalities in The NetherlandsBased on the SPARQL query example Replace Q1075310 by a boat class to get a map of that boat class. Map of sailboats home ports Map and list of municipalities in The NetherlandsBased on the SPARQL query example Replace Q1075310 by a boat class to get a map of that boat class.

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Map of all sailboat (Q1075310) home ports (P504)
#boat = wikidata item id (qid)
#home_portLabel = home port name
#home_port_coord = home port coordinates
#boatLabel = wikidata item name
#boat_name (optional) = boat name
#image (optional) = picture

#defaultView:Map
SELECT DISTINCT ?boat ?boatLabel ?boat_name ?instance_ofLabel ?home_portLabel ?image ?home_port_coord WHERE {
  ?boat wdt:P31/wdt:P279* wd:Q1075310; #'?boat' are 'instance of'(P31) and any number of 'subclass of' (P279*) of 'sailboat'(Q1075310)
        wdt:P31 ?instance_of; #'?boat' 'instance of' (P31) are '?instance_of'
        wdt:P504 ?home_port . #'?boat' 'home port' (P504) are '?home_port'
  #filter out home ports that are no longer current (home port (P504) with an 'end time' qualifier (P582))
  ?boat p:P504 ?statement1 .
  ?statement1 ps:P504 ?home_port .
  FILTER NOT EXISTS { ?statement1 pq:P582 ?x }
  ?home_port wdt:P625 ?home_port_coord. #'?home_port' 'coordinate location' (P625) are '?home_port_coord'

  OPTIONAL { ?boat wdt:P18 ?image . } 

  #'?boat" 'short name' (P1813) are '?boat_name'
  #filter out names that are no longer current (short name (P1813) with an 'end time' qualifier (P582))
  OPTIONAL {
    ?boat wdt:P1813 ?boat_name.
    ?boat p:P1813 ?statement2 .
    ?statement2 ps:P1813 ?boat_name .
    FILTER NOT EXISTS { ?statement2 pq:P582 ?x } 
  }  

  #xxxLabel is the label for any variable called xxx
  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("?boat"):::projected v9("?boat_name"):::projected v6("?home_port") v7("?home_port_coord"):::projected v8("?image"):::projected v5("?instance_of") v3("?statement1") v1("?statement2") v2("?x") a1((" ")) c4(["wd:Q1075310"]):::iri c14(["bd:serviceParam"]):::iri c16(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:qualifier/P582"--> e0v2 e0v1("?statement1"):::projected e0v2("?x"):::projected end f0--EXISTS--> f0e0 f0 --> v3 f0 --> c1 f0 --> v2 v3 --"p:qualifier/P582"--> v2 v4 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c4 v4 --"p:direct/P31"--> v5 v4 --"p:direct/P504"--> v6 v4 --"p:P504"--> v3 v3 --"p:statement/P504"--> v6 v6 --"p:direct/P625"--> v7 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P18".-> v8 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P1813".-> v9 v4 --"p:P1813"--> v1 v1 --"p:statement/P1813"--> v9 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c14 --"wikibase:language"--> c16 end