query-5287004f062d8c4d7a51cfd6fdf72a47
Query to Obtain City of the Airport [SOLVED]) However I am having difficulties trying to get the city where the airport is located. https://w.wiki/jxoI am interested in learning which airport is located in which city. With a little bit of work I had the code of looking up the airport from its ICAO code working.( looks promising, but a few attempts reveals that it would not only return the city of the airport, but also the province, the state, the municipality, etc. For example, RJAA (Narita International Airport near Tokyo, Japan) has both Narita (the city) and Chiba Perfecture listed there, KUNV (University Park Airport in State College, Pennsylvania, USA) only has Pensylvania listed, and ZSQD (Qingdao Liuting International Airport in Qingdao, Shandong, China) only has Chengyang District (one level lower than city) listed. (P131)located in the administrative territorial entity I came with two solutions but failed to put the codes together. and set up a filter to remove anything that is not a city. wdt:P131The first solution is to keep using the
Use at
- https://query.wikidata.org/sparql
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#>
SELECT ?airport ?airportLabel ?airportIn ?airportInLabel ?airportInType ?airportInTypeLabel WHERE {
?airport wdt:P239 "RJAA".
{ ?airport wdt:P131 ?airportIn. }
{ ?airportIn wdt:P31 ?airportInType. }
FILTER(EXISTS { ?airportInType wdt:P279 wd:Q515. })
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}