datasets / un-locode

United Nations Codes for Trade and Transport Locations (UN/LOCODE) and Country Codes
https://datahub.io/core/un-locode
146 stars 56 forks source link

No way to know what the IATA is unless it doesn't match the location #24

Closed cristan closed 6 months ago

cristan commented 8 months ago

About IATA: the latest secretariat notes has this:

The fact that some IATA 3-letter codes differ from the 3-letter part of the existing codes for the same places in UN/LOCODE has caused problems for users. In order to resolve this problem, the UN/LOCODE Expert Group agreed to introduce a separate column, to be used only in cases where the IATA code deviates from UN/LOCODE. In all other cases, the presence of an airport function code would mean that the code elements are identical.

So I read this as that if the function of a location contains a 4 and the IATA field isn't filled, the last 3 characters of the unlocode will be the IATA.

But then I ran this query (on the unlocode data):

SELECT 
    t.location,
    COUNT(*) AS duplicate_count
FROM (
    SELECT 
        CASE 
            WHEN IATA != '' THEN IATA 
            ELSE location 
        END AS location
    FROM 
        CodeList
    WHERE 
        function LIKE '%4%'
) AS t
WHERE 
    t.location != ''
GROUP BY 
    t.location
HAVING 
    COUNT(*) > 1;

And I got 583 entries with a duplicate IATA. Some examples (and check them out on the cool site I made with your data 😁):

https://unlocode.info/BRAAA vs https://unlocode.info/PFAAA https://unlocode.info/AEAAN vs https://unlocode.info/BRAAN https://unlocode.info/MLAAO vs https://unlocode.info/VEAAO https://unlocode.info/WSAAU vs https://unlocode.info/KZAAU https://unlocode.info/GTAAZ vs https://unlocode.info/USAAZ

The most common issue can be described with the first result: https://unlocode.info/PFAAA is correct: that is the real city of the airport with the IATA AAA. https://unlocode.info/BRAAA is incorrect, or is isn't it? The thing is, Araçuaí does have an airport, but it's too small to have an IATA. But there's currently no way to me to know that PFAAA has AAA as IATA is AAA and BRAAA doesn't.

Also filling the IATA column for entries whose location match the IATA would fix this issue. However, this is not how the unlocode database currently works. Any chance this can be changed? Or is it simply not in scope to be able to determine the IATA from a unlocode entry? Or am I missing something?

sabas commented 8 months ago

I'm a bit sad you are using Google Maps instead of OpenStreetMap lol I think that the answer would be that it's out of scope at this moment, but perhaps we could fix this in some way, I need to ask... Probably it needs discussion in the Advisory body.

cristan commented 8 months ago

Alright, what I do now is when there's an airport in the function codes, and there's no explicit IATA defined, that I show the last 3 characters of the UNLOCODE as "Possible IATA". I think that's the best I can do for now.

Also, I tried out OpenStreetMap :D I have to get used to it and I'm not sure yet if it'll work with what I use the site for most of the time (figuring out if the unlocodes location is actually correct), but I like it so far :)

sabas commented 8 months ago

The location coordinates are mostly correct, but often they're plainly wrong (and in that case it needs a DMR to fix). For the IATA code you could crossreference with a IATA dataset like https://github.com/jbrooksuk/JSON-Airports/blob/master/airports.json ?

If you need some assistance you can send me an email :)

sabas commented 6 months ago

IATA codes are kept for legacy, and will be removed once a new publication system is involved