5
$\begingroup$

Mathematica's AirportData[] is hopelessly outdated.

I'm trying to manually add entries for some common ICAO airport codes, such as OTHH (Doha) or FAOR (Johannesburg)

store = EntityStore["Airport" -> 
   <|"Entities" -> 
     <|"JNB Airport" -> <|"ICAO" -> "FAOR", 
        "coordinates" -> 
         CityData[{"Johannesburg", "Gauteng", "SouthAfrica"}, 
          "Coordinates"] |>,
      "DOH Airport" -> <|"ICAO" -> "OTHH", 
        "coordinates" -> 
         CityData[{{"Doha", "Doha", "Qatar"}}, "Coordinates"] |>
      |>
    |>]
EntityRegister[store]
AirportData["FAOR"]

Gives

Missing["UnknownEntity", {"Airport", "FAOR"}]

How do I affiliate an entity with AirportData[] without also deleting all the other elements in AirportData[]

$\endgroup$

2 Answers 2

2
+50
$\begingroup$

(Not really an answer, but too long for a comment)

I am not sure whether I should consider the documentation entirely clear about that. But from the details section in ref/EntityRegister):

Entity types that appear in EntityStores[] are considered before built-in entity types.

This I would read so that if you register an entity-store for type "Airport", then only that store will be searched for entries when using either Entity["Airport",...] or AirportData. And this is what seems to happen in your case and is in agreement with the documentation.

Consequently, only chance I see to achieve what you want would be to read out all data from the internal store, add/replace what you need and register that new entity-store. The main task here would be to do that in an efficient way, which most probably would need some spelunking where the internal "Airport" store comes from...

$\endgroup$
1
$\begingroup$

Maybe something like this:

newStore = 
 EntityStore[
  "Airport" -> <|
    "Entities" -> <|
      "FAOR Airport" -> <|
        "FullName" -> "O.R. Tambo International Airport", 
        "ICAO" -> "FAOR", "IATA" -> "JNB", 
        "Coordinates" -> {-26.1391667, 28.246}, 
        "TimeZone" -> "Africa/Johannesburg"|>, 
      "OTHH Airport" -> <|"FullName" -> "Hamad International Airport",
         "ICAO" -> "OTHH", "IATA" -> "DOH", 
        "Coordinates" -> {25.2611, 51.565}, 
        "TimeZone" -> "Asia/Qatar"|>|>|>]
EntityRegister[newStore]
Entity["Airport", "FAOR Airport"]
Entity["Airport", "OTHH Airport"]
$\endgroup$
1
  • 2
    $\begingroup$ For me this replaces the internal entity store for airports, so that only the two entries in the new store are available. Is this different for you? I think the question was exactly about that: how to add to an existing store so that all other entries of the existing store would still be available. $\endgroup$ Commented May 9, 2023 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.