Created
December 10, 2023 18:27
-
-
Save StellarStoic/76fb9fcc8710f637f3fc308adaad85e1 to your computer and use it in GitHub Desktop.
airport SPARQL query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
?airportName ?pageBanner ?logo ?icao ?iata ?faa ?website ?operator ?opening ?status ?elevation ?elevationUnitLabel ?image | |
?runway ?runwayLabel ?lengthValue ?lengthUnitLabel ?widthValue ?widthUnitLabel ?materialLabel | |
WHERE { | |
BIND(wd:Q8685 AS ?airport) # JFK International Airport's Wikidata ID | |
# Fetching general airport information | |
OPTIONAL { ?airport wdt:P373 ?airportName. } | |
OPTIONAL { ?airport wdt:P948 ?pageBanner. } | |
OPTIONAL { ?airport wdt:P154 ?logo. } | |
OPTIONAL { ?airport wdt:P239 ?icao. } | |
OPTIONAL { ?airport wdt:P238 ?iata. } | |
OPTIONAL { ?airport wdt:P240 ?faa. } | |
OPTIONAL { ?airport wdt:P856 ?website. } | |
OPTIONAL { ?airport wdt:P137 ?operator. } | |
OPTIONAL { ?airport wdt:P571 ?opening. } | |
OPTIONAL { ?airport wdt:P5817 ?status. } | |
# the elevationUnitLabel has been retreived successfully | |
OPTIONAL { | |
?airport p:P2044 ?elevationStatement. | |
?elevationStatement psv:P2044 ?elevationValueNode. | |
?elevationValueNode wikibase:quantityAmount ?elevation. | |
OPTIONAL { | |
?elevationValueNode wikibase:quantityUnit ?elevationUnit. | |
?elevationUnit rdfs:label ?elevationUnitLabel FILTER(LANG(?elevationUnitLabel) = "en") | |
} | |
} | |
OPTIONAL { ?airport wdt:P18 ?image. } | |
# Fetching runway specific information | |
OPTIONAL { | |
?airport p:P529 ?runwayStatement. | |
?runwayStatement ps:P529 ?runway. | |
# Accessing the runway label | |
OPTIONAL { | |
?runway wdt:P1813 ?runwayLabel. | |
} | |
# Accessing the length qualifier | |
OPTIONAL { | |
?runwayStatement pq:P2043 ?lengthValue. | |
} | |
# Accessing the width qualifier | |
OPTIONAL { | |
?runwayStatement pq:P2049 ?widthValue. | |
} | |
# Accessing the material qualifier | |
OPTIONAL { | |
?runwayStatement pq:P186 ?material. | |
OPTIONAL { ?material rdfs:label ?materialLabel FILTER(LANG(?materialLabel) = "en") } | |
} | |
} | |
} |
Answer #2 with original unit converted into meters
SELECT
?airportName ?pageBanner ?logo ?icao ?iata ?faa ?website ?operator ?opening ?status ?elevation ?elevationUnitLabel ?image
?runway ?lengthValue ?lengthUnitLabel ?widthValue ?widthUnitLabel ?materialLabel
WHERE {
BIND(wd:Q8685 AS ?airport) # JFK International Airport's Wikidata ID
# Fetching general airport information
OPTIONAL { ?airport wdt:P373 ?airportName. }
OPTIONAL { ?airport wdt:P948 ?pageBanner. }
OPTIONAL { ?airport wdt:P154 ?logo. }
OPTIONAL { ?airport wdt:P239 ?icao. }
OPTIONAL { ?airport wdt:P238 ?iata. }
OPTIONAL { ?airport wdt:P240 ?faa. }
OPTIONAL { ?airport wdt:P856 ?website. }
OPTIONAL { ?airport wdt:P137 ?operator. }
OPTIONAL { ?airport wdt:P571 ?opening. }
OPTIONAL { ?airport wdt:P5817 ?status. }
OPTIONAL {
?airport p:P2044 ?elevationStatement.
?elevationStatement psn:P2044 ?elevationValueNode.
?elevationValueNode wikibase:quantityAmount ?elevation.
OPTIONAL {
?elevationValueNode wikibase:quantityUnit ?elevationUnit.
?elevationUnit rdfs:label ?elevationUnitLabel FILTER(LANG(?elevationUnitLabel) = "en")
}
}
OPTIONAL { ?airport wdt:P18 ?image. }
# Fetching runway specific information
OPTIONAL {
?airport p:P529 ?runwayStatement.
?runwayStatement ps:P529 ?runway.
# Accessing the length qualifier
OPTIONAL {
?runwayStatement pqn:P2043 ?lengthNode.
?lengthNode wikibase:quantityAmount ?lengthValue.
?lengthNode wikibase:quantityUnit ?lengthUnit.
}
# Accessing the width qualifier
OPTIONAL {
?runwayStatement pqn:P2049 ?widthNode.
?widthNode wikibase:quantityAmount ?widthValue.
?widthNode wikibase:quantityUnit ?widthUnit.
}
# Accessing the material qualifier
OPTIONAL {
?runwayStatement pq:P186 ?material.
OPTIONAL { ?material rdfs:label ?materialLabel FILTER(LANG(?materialLabel) = "en") }
}
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Answer #1 with original units