query-a759d1beb393d70c14bf828ac140be21

rq turtle/ttl

22:35, 16 February 2019 (UTC)) talk (Andrew Gray has a P131 but it doesn't have a complete chain up to Ontario. (Q94904)Niagara Central Airport You also need to bring this bit inside the overall P131 optional clause, but once you've done that it works correctly. It shows the top-level admin area (if one exists). If it has a P131 but that doesn't link into a chain going up to a province/territory, then it's blank. eg/ . So P31:Q2879 won't match any items at all - you need to add an extra P279 line to match a province/territory.(Q2879)province or territory of Canada , which is a subclass of (Q11828004)province of Canada Edit conflicted, but here's my answer anyway :-) A problem here is that Ontario is an instance of 22:41, 16 February 2019 (UTC)) talk (Andrew Gray has two (one the province, one the town). I'm not quite sure how the / syntax works though so I can't see why. (Q338950)Bamfield Water Aerodrome has one value (not a province) and (Q94904)Niagara Central Airport doesn't quite seem to work as expected - it returns all the P131 values, regardless of whether they're a town or a province. So OPTIONAL { ?airport wdt:P131/ wd:Q2879 ?localisation_administrative. }: looking at these two queries, your Bouzinac@ OPTIONAL { ?airport wdt:P131 ?localisation_administrative.Hi there, thank you, I buy the 23:03, 16 February 2019 (UTC)) talk (Bouzinac The data is often poor on obscure airports… So data is not clean :/ ?localisation_administrative wdt:P31 ?type . ?type wdt:P279 wd:Q2879. }22:56, 18 February 2019 (UTC)) talk (Bouzinac renders an empty column… Any thoughts? .Q35657 ?airport wdt:P131 ?localisation_administrative. ?localisation_administrative wdt:P31 ?type. ?type wdt:P279 wd: does show any level of US territories [so does'nt limit to US States] but .Q852446?airport wdt:P131 ?localisation_administrative. ?localisation_administrative wdt:P31 ?type. ?type wdt:P279 wd:Hello again, I'm surprised by this code : 23:40, 18 February 2019 (UTC)) talk (Tagishsimon whereas if you're interested in Q852446 you require the P279 lookup. --.Q35657 ?airport wdt:P131 ?localisation_administrative. ?localisation_administrative wdt:P31 wd: so if you want to look for locations that are part of Q35657 only, you'd use (Q829)Utah Q35657 is a P279 of Q852446, but Q35657 has no useful P279 relation with, say Like this (I added a ) ? TODO

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#>
PREFIX wdno: <http://www.wikidata.org/prop/novalue/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT DISTINCT ?localisation_administrativeLabel ?airport ?airportLabel (SAMPLE(?coord) AS ?coord) ?ICAO ?IATA (SAMPLE(?Local_Code) AS ?Local_Code) WHERE {
 ?airport (wdt:P31/wdt:P279*) wd:Q62447.
?airport wdt:P17 wd:Q30.
MINUS { ?airport wdt:P576 _:b2. }
MINUS { ?airport wdt:P582 _:b3. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q1311670. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q7373622. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q2265915. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q44665966. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q782667. }
MINUS { ?airport rdf:type wdno:P17. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr,[AUTO_LANGUAGE]". }
OPTIONAL { ?airport wdt:P625 ?coord. }
OPTIONAL { ?airport wdt:P239 ?ICAO. }
OPTIONAL { ?airport wdt:P238 ?IATA. }
OPTIONAL { ?airport wdt:P240 ?Local_Code. }
OPTIONAL {
?airport wdt:P131* ?localisation_administrative.
?localisation_administrative wdt:P31 ?type.
?type wdt:P279* wd:Q35657.
}
}
GROUP BY ?airport ?airportLabel ?ICAO ?IATA ?localisation_administrative ?localisation_administrativeLabel
ORDER BY ?coord

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?IATA"):::projected v3("?ICAO"):::projected v8("?Local_Code"):::projected v2("?airport"):::projected v8("?coord"):::projected v6("?localisation_administrative") v7("?type") a2((" ")) a3((" ")) a1((" ")) a4((" ")) a5((" ")) a6((" ")) a7((" ")) a8((" ")) c9(["wd:Q7373622"]):::iri c10(["wd:Q2265915"]):::iri c12(["wd:Q782667"]):::iri c5(["wd:Q30"]):::iri c14(["wdno:P17"]):::iri c3(["wd:Q62447"]):::iri c16(["bd:serviceParam"]):::iri c8(["wd:Q1311670"]):::iri c11(["wd:Q44665966"]):::iri c18(["en,fr,#91;AUTO_LANGUAGE#93;"]):::literal c24(["wd:Q35657"]):::iri v2 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c3 v2 --"wdt:P17"--> c5 subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P576"--> a2 end subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P582"--> a3 end subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P31"--> a4 a4 --"wdt:P279"--> c8 end subgraph minus3["MINUS"] style minus3 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P31"--> a5 a5 --"wdt:P279"--> c9 end subgraph minus4["MINUS"] style minus4 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P31"--> a6 a6 --"wdt:P279"--> c10 end subgraph minus5["MINUS"] style minus5 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P31"--> a7 a7 --"wdt:P279"--> c11 end subgraph minus6["MINUS"] style minus6 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P31"--> a8 a8 --"wdt:P279"--> c12 end subgraph minus7["MINUS"] style minus7 stroke-width:6px,fill:pink,stroke:red; v2 --"a"--> c14 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c16 --"wikibase:language"--> c18 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P625".-> v8 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P239".-> v3 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P238".-> v4 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P240".-> v8 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P131".-> v6 v6 --"wdt:P31"--> v7 v7 --"wdt:P279"--> c24 end bind10[/"sample(?coord)"/] v8 --o bind10 bind10 --as--o v8 bind11[/"sample(?Local_Code)"/] v8 --o bind11 bind11 --as--o v8