query-fd2babcbc7c99eb0777a9b70ab43f5d6

rq turtle/ttl

Deduplicate IATAHello I have this list :

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wdno: <http://www.wikidata.org/prop/novalue/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX schema: <http://schema.org/>

SELECT  ?item ?itemLabel ?countryLabel ?iata ?icao 
WHERE {
  OPTIONAL { ?item wdt:P238 ?iata. }
  OPTIONAL { ?item wdt:P239 ?icao. }
  OPTIONAL { ?item wdt:P17 ?country. }
  MINUS    { ?item wdt:P576 [].}                    # remove items with P576 (dissolved, abolished or demolished) as a main property
  MINUS    { ?item (wdt:P31/wdt:P279*) wd:Q782667. } # exclude motorways where plane can land
  MINUS    { ?item wdt:P31/wdt:P279* wd:Q44665966.} # exclude  airports being build
  MINUS    { ?item wdt:P31/wdt:P279* wd:Q2265915.}  # exclude vol à voile
  MINUS    {?item wdt:P582 [].}                    # remove items with P582 (end date) as a main property
  MINUS    { ?item a wdno:P17.}                    #exclude airports that aren't physically based in a country
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en". }
}
ORDER BY ?country ?natureLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?country") v4("?iata"):::projected v5("?icao"):::projected v3("?item"):::projected v2("?natureLabel") a1((" ")) a5((" ")) a2((" ")) a3((" ")) a4((" ")) c9(["wd:Q2265915"]):::iri c7(["wd:Q782667"]):::iri c12(["wdno:P17"]):::iri c14(["bd:serviceParam"]):::iri c16(["fr,en"]):::literal c8(["wd:Q44665966"]):::iri subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P238".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P239".-> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P17".-> v1 end subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v3 --"wdt:P576"--> a1 end subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v3 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c7 end subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v3 --"wdt:P31"--> a3 a3 --"wdt:P279"--> c8 end subgraph minus3["MINUS"] style minus3 stroke-width:6px,fill:pink,stroke:red; v3 --"wdt:P31"--> a4 a4 --"wdt:P279"--> c9 end subgraph minus4["MINUS"] style minus4 stroke-width:6px,fill:pink,stroke:red; v3 --"wdt:P582"--> a5 end subgraph minus5["MINUS"] style minus5 stroke-width:6px,fill:pink,stroke:red; v3 --"a"--> c12 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c14 --"wikibase:language"--> c16 end