query-8a399a98f1cb2b6d88c6dc8b9bf24a71

rq turtle/ttl

Objects on borders : do they have a part of (P361) ?

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#>
select 
  ?item ?itemLabel 
  (SAMPLE(?coor) as ?coor)
  (group_concat(DISTINCT ?natureLabel) as ?NATURE) 
  (group_concat(DISTINCT ?paysLabel; separator=", ") as ?PAYS) 
  (group_concat(DISTINCT ?partiedeLabel; separator=" // ") AS ?partiedeL)
WHERE
{  
  {  SELECT ?item ?itemLabel ?nature ?natureLabel ?coor ?pays ?paysLabel ?partiede ?partiedeLabel 
     WHERE
     {
      ?item wdt:P31/wdt:P279* wd:Q25296884 .
  MINUS { ?item (wdt:P31/wdt:P279*) wd:Q4366834. } # exclude cours d'eau
  MINUS { ?item (wdt:P31/wdt:P279*) wd:Q218719. } # exclude contr^le frontalier
  MINUS { ?item wdt:P361 wd:Q3089219. } #Remove maritime borders
  MINUS { ?item (wdt:P31/wdt:P279*) wd:Q1402443. } # exclude railway station border
  MINUS { ?item wdt:P361 wd:Q1292279. } #Remove political borders (not international)
  MINUS { ?item wdt:P361 wd:Q67457910. } #Remove municipal borders 
  MINUS { ?item wdt:P361 wd:Q67218438. } #Remove air borders
  MINUS { ?item wdt:P576 _:b2. }
  MINUS { ?item p:P361 [ps:P361 wd:Q1292279 ; pq:P576 ?P576 ] . }
      ?item wdt:P31 ?nature.
      ?item wdt:P17 ?pays.
      OPTIONAL { ?item wdt:P361 ?partiede }
      OPTIONAL { ?item wdt:P625 ?coor }
       BIND(COALESCE(?partiede,"vide") AS ?variable).
       filter(?variable="vide")
      SERVICE wikibase:label {       bd:serviceParam wikibase:language "fr,en"   }
     } #
  } #
} group by ?item ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v11("?NATURE") v3("?P576") v12("?PAYS") v11("?coor"):::projected v2("?item"):::projected v4("?nature") v8("?natureLabel"):::projected v6("?partiede") v13("?partiedeL") v10("?partiedeLabel"):::projected v5("?pays") v9("?paysLabel"):::projected v8("?variable") a5((" ")) a1((" ")) a2((" ")) a3((" ")) a4((" ")) a6((" ")) c6(["wd:Q218719"]):::iri c4(["wd:Q25296884"]):::iri c20(["bd:serviceParam"]):::iri c22(["fr,en"]):::literal c8(["wd:Q3089219"]):::iri c11(["wd:Q67457910"]):::iri c5(["wd:Q4366834"]):::iri c10(["wd:Q1292279"]):::iri c9(["wd:Q1402443"]):::iri c12(["wd:Q67218438"]):::iri f0[["?variable = 'vide'"]] f0 --> v8 v2 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c4 subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v2 --"p:direct/P31"--> a2 a2 --"p:direct/P279"--> c5 end subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v2 --"p:direct/P31"--> a3 a3 --"p:direct/P279"--> c6 end subgraph minus3["MINUS"] style minus3 stroke-width:6px,fill:pink,stroke:red; v2 --"p:direct/P361"--> c8 end subgraph minus4["MINUS"] style minus4 stroke-width:6px,fill:pink,stroke:red; v2 --"p:direct/P31"--> a4 a4 --"p:direct/P279"--> c9 end subgraph minus5["MINUS"] style minus5 stroke-width:6px,fill:pink,stroke:red; v2 --"p:direct/P361"--> c10 end subgraph minus6["MINUS"] style minus6 stroke-width:6px,fill:pink,stroke:red; v2 --"p:direct/P361"--> c11 end subgraph minus7["MINUS"] style minus7 stroke-width:6px,fill:pink,stroke:red; v2 --"p:direct/P361"--> c12 end subgraph minus8["MINUS"] style minus8 stroke-width:6px,fill:pink,stroke:red; v2 --"p:direct/P576"--> a5 end subgraph minus9["MINUS"] style minus9 stroke-width:6px,fill:pink,stroke:red; a6 --"p:statement/P361"--> c10 a6 --"p:qualifier/P576"--> v3 v2 --"p:P361"--> a6 end v2 --"p:direct/P31"--> v4 v2 --"p:direct/P17"--> v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P361".-> v6 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P625".-> v11 end bind10[/"?partiede'vide'"/] v6 --o bind10 bind10 --as--o v8 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c20 --"wikibase:language"--> c22 end bind15[/"sample(?coor)"/] v11 --o bind15 bind15 --as--o v11 bind16[/"?natureLabel"/] v8 --o bind16 bind16 --as--o v11 bind17[/"?paysLabel"/] v9 --o bind17 bind17 --as--o v12 bind18[/"?partiedeLabel"/] v10 --o bind18 bind18 --as--o v13