query-b2bf780ca5a3c277a0a40a875e16e54c

rq turtle/ttl

All airports, sorted by country

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#>
SELECT DISTINCT ?airport ?airportLabel ?pays ?paysLabel (SAMPLE(?coord) AS ?coord)
  ?ICAO ?IATA (SAMPLE(?Local_Code) AS ?Local_Code)
WHERE
{

{
  SELECT DISTINCT ?airport
  WHERE
  {
    ?airport (wdt:P31/wdt:P279*) wd:Q62447.
    #?airport wdt:P17 wd:Q408.                                       # make a country filter
    MINUS { ?airport wdt:P576 _:b2. }                                # remove items with P576 (dissolved, abolished or demolished) as a main property
    MINUS { ?airport wdt:P582 _:b3. }                                # remove items with P582 (end date) as a main property
  MINUS {
    ?airport (wdt:P31/(wdt:P279*)) ?thing.
    VALUES ?thing {
      wd:Q695850      wd:Q2265915      wd:Q1311670      wd:Q7373622      wd:Q782667      wd:Q502074      wd:Q44665966      wd:Q2071567
      wd:Q3631092     wd:Q4930096
    }
  } 
    MINUS { ?airport a wdno:P17.}                                    # exclude airports that aren't physically based in a country
  }
}  ?airport wdt:P625  ?coord. 
  OPTIONAL { ?airport wdt:P239  ?ICAO. }
  OPTIONAL { ?airport wdt:P238  ?IATA. }
  ?airport wdt:P17   ?pays.
  OPTIONAL { ?airport (wdt:P240|wdt:P5699|wdt:P5746|wdt:P5851|wdt:P6120) ?Local_Code. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr,[AUTO_LANGUAGE]". }
}
GROUP BY ?airport ?airportLabel ?ICAO ?IATA ?pays ?paysLabel
ORDER BY ?paysLabel ?coord

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?IATA"):::projected v5("?ICAO"):::projected v9("?Local_Code"):::projected v3("?airport"):::projected v9("?coord"):::projected v7("?pays"):::projected v1("?paysLabel"):::projected v5("?thing") a2((" ")) a3((" ")) a1((" ")) a4((" ")) c7(["wdno:P17"]):::iri c3(["wd:Q62447"]):::iri c18(["bd:serviceParam"]):::iri c20(["en,fr,#91;AUTO_LANGUAGE#93;"]):::literal v3 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c3 subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v3 --"wdt:P576"--> a2 end subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v3 --"wdt:P582"--> a3 end subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v3 --"wdt:P31"--> a4 a4 --"wdt:P279"--> v5 bind3[/VALUES ?thing/] bind3-->v5 bind30(["wd:Q695850"]) bind30 --> bind3 bind31(["wd:Q2265915"]) bind31 --> bind3 bind32(["wd:Q1311670"]) bind32 --> bind3 bind33(["wd:Q7373622"]) bind33 --> bind3 bind34(["wd:Q782667"]) bind34 --> bind3 bind35(["wd:Q502074"]) bind35 --> bind3 bind36(["wd:Q44665966"]) bind36 --> bind3 bind37(["wd:Q2071567"]) bind37 --> bind3 bind38(["wd:Q3631092"]) bind38 --> bind3 bind39(["wd:Q4930096"]) bind39 --> bind3 end subgraph minus4["MINUS"] style minus4 stroke-width:6px,fill:pink,stroke:red; v3 --"a"--> c7 end v3 --"wdt:P625"--> v9 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P239".-> v5 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P238".-> v6 end v3 --"wdt:P17"--> v7 subgraph optional2["(optional)"] style optional2 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; subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; subgraph union3[" Union "] subgraph union3l[" "] style union3l fill:#abf,stroke-dasharray: 3 3; v3 -."wdt:P6120".-> v9 end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P5851"--> v9 end union3r <== or ==> union3l end end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P5746"--> v9 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P5699"--> v9 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P240"--> v9 end union0r <== or ==> union0l end end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c18 --"wikibase:language"--> c20 end bind7[/"sample(?coord)"/] v9 --o bind7 bind7 --as--o v9 bind8[/"sample(?Local_Code)"/] v9 --o bind8 bind8 --as--o v9